cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

XML LoadXML

BryanK
14-Alexandrite

XML LoadXML

Hi All,

I have a Site that I am reading xml data from. The problem that I have is using the loadXML script.

if I run postman I get the following.

<?xml version="1.0" encoding="UTF-8"?>

<Rates>

    <Rate Symbol="EURUSD">

        <Bid>1.07607</Bid>

        <Ask>1.07632</Ask>

        <High>1.07633</High>

        <Low>1.07311</Low>

        <Direction>0</Direction>

        <Last>22:40:33</Last>

    </Rate>

</Rates>

I have created a service that I want to use that will pull that information. as shown below.

var params = {
proxyScheme: undefined /* STRING */,
headers: undefined /*'Rates' /* JSON */,
url: http://thisisthewebsiteurl /* STRING */,
timeout: '60' /* NUMBER */,

};

// result: XML
var xml_file = Resources["ContentLoaderFunctions"].LoadXML(params);


var params = {
fieldMap: undefined /* INFOTABLE */,
xml: xml_file /* XML */,
rowPath: 'Rate'  /* STRING */,
dataShape: 'forex_xml' /* DATASHAPENAME */
};

// result: INFOTABLE
var result= Resources["UniversalConverterFunctions"].ConvertXML(params);

this gives me the following.

rates.PNG

where symbol is missing.

If I take rowPath: 'Rate'  out I get nothing.

The issue I believe is that the <rate Symbol=xxxx> is embedded.

Any idea how I can handle that seeing as I cant do anything with the xml file I'm reading.

1 ACCEPTED SOLUTION

Accepted Solutions

Try adding this after the line 'var xml_file = ...'

for(var index = 0; index < xml_file.Rate.length(); index++)

    xml_file.Rate[index].Symbol = xml_file.Rate[index].@Symbol.toString();

View solution in original post

1 REPLY 1

Try adding this after the line 'var xml_file = ...'

for(var index = 0; index < xml_file.Rate.length(); index++)

    xml_file.Rate[index].Symbol = xml_file.Rate[index].@Symbol.toString();

Top Tags