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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

XML LoadXML

BryanK
16-Pearl

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.

ACCEPTED SOLUTION

Accepted Solutions
ptc-6292103
12-Amethyst
(To:BryanK)

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
ptc-6292103
12-Amethyst
(To:BryanK)

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();

Announcements


Top Tags