1 Reply Latest reply on Mar 23, 2017 2:43 PM by chadha RSS
    bkirchner-2 Explorer

    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.

      • Re: XML LoadXML
        chadha Apprentice

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