Reading XML file in Navision

MagnoMagno Posts: 168Member
edited 2014-11-17 in Navision Attain
Hi, something doesn't work in my code, but i don't see it...
=========ImportXMLFile(pFilePath : Text[1024])=========
IF ISCLEAR(lautXMLDocument) THEN
  CREATE(lautXMLDocument);

lautXMLDocument.load(pFilePath);
lautXMLNodeList := lautXMLDocument.getElementsByTagName('Results/ProposedPrices/ProposedPriceItem');
lautXMLNode := lautXMLNodeList.item(0);
WHILE NOT ISCLEAR(lautXMLNode) DO BEGIN
  tSiteID := lautXMLNode.selectNodes('Siteid').item(0).text;
  tEffectiveDate := lautXMLNode.selectNodes('effectiveDate').item(0).text;
  tProductCode := lautXMLNode.selectNodes('productcode').item(0).text;
  lautXMLNodeList2 := lautXMLNode.selectNodes('ProposedPrice');
  tCurrency := lautXMLNodeList2.item(0).selectNodes('currencyunit').item(0).text;
  tPriceValue := lautXMLNodeList2.item(0).selectNodes('pricevalue').item(0).text;
  lautXMLNode := lautXMLNodeList.nextNode;
END;

This are my variables:
    Name DataType Subtype Length lautXMLDocument Automation 'Microsoft XML, v3.0'.DOMDocument lautXMLNodeList Automation 'Microsoft XML, v3.0'.IXMLDOMNodeList lautXMLNode Automation 'Microsoft XML, v3.0'.IXMLDOMNode lautXMLNodeList2 Automation 'Microsoft XML, v3.0'.IXMLDOMNodeList tSiteID Text 30 tEffectiveDate Text 30 tProductCode Text 30 tPriceValue Text 30 tCurrency Text 30


The error is thrown when i try to put the text in the textvars.
It says:
This automation variable has not been instantiated. You can instantiate it by either creating or assigning it.

As i see, none of the above automation objects are or instantiated(lautXMLDocument) or assigned (all the rest...)

Hope anyone can help me on this one
There are no bugs, only random undocumented features...
---
My Blog: http://NAV-Magno.be

Comments

  • MagnoMagno Posts: 168Member
    my xml file looks something like this:
      <?xml version="1.0" ?> 
    - <Results>
       - <ProposedPrices>
         - <ProposedPriceItem>
             <siteID>145236</siteID> 
             <effectiveDate xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="dateTime">2004-11-16T10:55:43.000</effectiveDate> 
             <productCode>ULSP</productCode> 
           - <ProposedPrice>
              <currencyUnit /> 
    	  <priceValue xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="float">82.9</priceValue> 
             </ProposedPrice>
           - <notes>
             - <note>
                <author>ADMIN</author> 
                <subject>New proposed price differs from last proposed price</subject> 
                <content>New price 85.9, last proposed price 83.9</content> 
        	    <timestamp xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="datetime">2004-11-16T10:55:43.000</timestamp> 
        	   </note>
             </notes>
          </ProposedPriceItem>
        </ProposedPrices>
      - <ProposedPrices>
        - <ProposedPriceItem>
            <siteID>145236</siteID> 
            <effectiveDate xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="dateTime">2004-11-16T10:55:43.000</effectiveDate> 
            <productCode>ULSD</productCode> 
          - <ProposedPrice>
              <currencyUnit /> 
              <priceValue xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="float">85.9</priceValue> 
            </ProposedPrice>
            <notes /> 
          </ProposedPriceItem>
        </ProposedPrices>
      - <ProposedPrices>
        - <ProposedPriceItem>
            <siteID>145236</siteID> 
            <effectiveDate xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="dateTime">2004-11-16T10:55:43.000</effectiveDate> 
            <productCode>ULSF</productCode> 
          - <ProposedPrice>
              <currencyUnit /> 
              <priceValue xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="float">90.9</priceValue> 
            </ProposedPrice>
            <notes /> 
          </ProposedPriceItem>
        </ProposedPrices>
      - <ProposedPrices>
        - <ProposedPriceItem>
            <siteID>145236</siteID> 
            <effectiveDate xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="dateTime">2004-11-16T10:55:43.000</effectiveDate> 
            <productCode>ULSE</productCode> 
          - <ProposedPrice>
              <currencyUnit /> 
              <priceValue xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="float">89.9</priceValue> 
            </ProposedPrice>
          - <notes>
            - <note>
                <author>ADMIN</author> 
                <subject>Failed Maximum Price Movement rule</subject> 
                <content>Price movement (92.80000000000001) beyond maximum increase limit (5)</content> 
                <timestamp xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="datetime">2004-11-16T10:55:43.000</timestamp> 
              </note>
            - <note>
               <author>ADMIN</author> 
               <subject>New proposed price differs from last proposed price</subject> 
               <content>New price 92.9, last proposed price 90.9</content> 
               <timestamp xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="datetime">2004-11-16T10:55:43.000</timestamp> 
              </note>
           </notes>
          </ProposedPriceItem>
         </ProposedPrices>
       </Results>
    

    i don't need the notes in the file, only the site, price, effective date, productcode and currencyunit
    There are no bugs, only random undocumented features...
    ---
    My Blog: http://NAV-Magno.be
  • MagnoMagno Posts: 168Member
    found the solution,
    the bastard is case sensitive...
    There are no bugs, only random undocumented features...
    ---
    My Blog: http://NAV-Magno.be
  • JaanuJaanu Posts: 44Member
    Hi Magno,
    I'm facing the same issue above. can you please what is the solution for it?

    My Code in Codeunit for Load & Import Data through XML is

    CLEAR(XMLHTTP);
    CREATE(XMLHTTP,TRUE,TRUE);


    XMLHTTP.open('POST','http://www.floatrates.com/daily/USD.xml',0);
    XMLHTTP.setRequestHeader('Content-type','text/xml');
    XMLHTTP.send('');

    CLEAR(XMLDoc);
    CREATE(XMLDoc,TRUE,TRUE);

    XMLDoc.load(XMLHTTP.responseXML);

    XMLNodes := XMLDoc.getElementsByTagName('item/title');
    XMLNode := XMLNodes.item(0);
    WHILE NOT ISCLEAR(XMLNode) DO BEGIN
    codCurrency := XMLNode.selectNodes('title').item(0).text;
    MESSAGE('%1',codCurrency);
    END;

    My XML File has

    This XML file does not appear to have any style information associated with it. The document tree is shown below.
    <channel>
    <title>Float Rates: Daily Foreign Exchange Rates</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>
    Daily foreign exchange rates from the Float Rates. Published at Fri, 14 Nov 2014 00:00:01 GMT.
    </description>
    <language>en</language>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <lastBuildDate>Fri, 14 Nov 2014 00:00:01 GMT</lastBuildDate>
    <item>
    <title>1 USD = 0.802786 EUR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 0.802786 Euro</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>EUR</targetCurrency>
    <exchangeRate>0.802786</exchangeRate>
    </item>
    <item>
    <title>1 USD = 0.635141 GBP</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 0.635141 U.K. Pound Sterling</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>GBP</targetCurrency>
    <exchangeRate>0.635141</exchangeRate>
    </item>
    <item>
    <title>1 USD = 0.964769 CHF</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 0.964769 Swiss Franc</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>CHF</targetCurrency>
    <exchangeRate>0.964769</exchangeRate>
    </item>
    <item>
    <title>1 USD = 115.530405 JPY</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 115.530405 Japanese Yen</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>JPY</targetCurrency>
    <exchangeRate>115.530405</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.132932 CAD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.132932 Canadian Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>CAD</targetCurrency>
    <exchangeRate>1.132932</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.145217 AUD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.145217 Australian Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>AUD</targetCurrency>
    <exchangeRate>1.145217</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.759846 ANG</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.759846 Neth. Antillean Guilder</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>ANG</targetCurrency>
    <exchangeRate>1.759846</exchangeRate>
    </item>
    <item>
    <title>1 USD = 2.251298 TRY</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 2.251298 Turkish Lira</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>TRY</targetCurrency>
    <exchangeRate>2.251298</exchangeRate>
    </item>
    <item>
    <title>1 USD = 101.656107 PKR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 101.656107 Pakistani rupee</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>PKR</targetCurrency>
    <exchangeRate>101.656107</exchangeRate>
    </item>
    <item>
    <title>1 USD = 57.599981 KGS</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 57.599981 Kyrgyzstan Som</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>KGS</targetCurrency>
    <exchangeRate>57.599981</exchangeRate>
    </item>
    <item>
    <title>1 USD = 593.657433 CLP</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 593.657433 Chilean peso</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>CLP</targetCurrency>
    <exchangeRate>593.657433</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.000000 BSD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.000000 Bahamian Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>BSD</targetCurrency>
    <exchangeRate>1.000000</exchangeRate>
    </item>
    <item>
    <title>1 USD = 130.921338 LKR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 130.921338 Sri Lanka rupee</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>LKR</targetCurrency>
    <exchangeRate>130.921338</exchangeRate>
    </item>
    <item>
    <title>1 USD = 12,192.178459 IDR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 12,192.178459 Indonesian rupiah</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>IDR</targetCurrency>
    <exchangeRate>12,192.178459</exchangeRate>
    </item>
    <item>
    <title>1 USD = 7.811032 GTQ</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 7.811032 Guatemalan Quetzal</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>GTQ</targetCurrency>
    <exchangeRate>7.811032</exchangeRate>
    </item>
    <item>
    <title>1 USD = 6.291232 VEF</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 6.291232 Venezuelan Bolivar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>VEF</targetCurrency>
    <exchangeRate>6.291232</exchangeRate>
    </item>
    <item>
    <title>1 USD = 31.570100 MUR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 31.570100 Mauritian rupee</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>MUR</targetCurrency>
    <exchangeRate>31.570100</exchangeRate>
    </item>
    <item>
    <title>1 USD = 2.935762 PEN</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 2.935762 Peruvian Nuevo Sol</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>PEN</targetCurrency>
    <exchangeRate>2.935762</exchangeRate>
    </item>
    <item>
    <title>1 USD = 84.595200 DZD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 84.595200 Algerian Dinar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>DZD</targetCurrency>
    <exchangeRate>84.595200</exchangeRate>
    </item>
    <item>
    <title>1 USD = 7.755244 HKD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 7.755244 Hong Kong Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>HKD</targetCurrency>
    <exchangeRate>7.755244</exchangeRate>
    </item>
    <item>
    <title>1 USD = 3.640000 QAR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 3.640000 Qatari rial</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>QAR</targetCurrency>
    <exchangeRate>3.640000</exchangeRate>
    </item>
    <item>
    <title>1 USD = 2.850002 TMT</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 2.850002 New Turkmenistan Manat</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>TMT</targetCurrency>
    <exchangeRate>2.850002</exchangeRate>
    </item>
    <item>
    <title>1 USD = 22.190043 CZK</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 22.190043 Czech koruna</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>CZK</targetCurrency>
    <exchangeRate>22.190043</exchangeRate>
    </item>
    <item>
    <title>1 USD = 95.614573 XPF</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 95.614573 CFP Franc</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>XPF</targetCurrency>
    <exchangeRate>95.614573</exchangeRate>
    </item>
    <item>
    <title>1 USD = 180.870904 KZT</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 180.870904 Kazakhstani tenge</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>KZT</targetCurrency>
    <exchangeRate>180.870904</exchangeRate>
    </item>
    <item>
    <title>1 USD = 112.817614 JMD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 112.817614 Jamaican Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>JMD</targetCurrency>
    <exchangeRate>112.817614</exchangeRate>
    </item>
    <item>
    <title>1 USD = 2.771989 LTL</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 2.771989 Lithuanian Litas</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>LTL</targetCurrency>
    <exchangeRate>2.771989</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.266294 NZD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.266294 New Zealand dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>NZD</targetCurrency>
    <exchangeRate>1.266294</exchangeRate>
    </item>
    <item>
    <title>1 USD = 0.783901 AZN</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 0.783901 Azerbaijan Manat</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>AZN</targetCurrency>
    <exchangeRate>0.783901</exchangeRate>
    </item>
    <item>
    <title>1 USD = 9.293680 BWP</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 9.293680 Botswana pula</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>BWP</targetCurrency>
    <exchangeRate>9.293680</exchangeRate>
    </item>
    <item>
    <title>1 USD = 44.873352 PHP</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 44.873352 Philippine Peso</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>PHP</targetCurrency>
    <exchangeRate>44.873352</exchangeRate>
    </item>
    <item>
    <title>1 USD = 3.750000 SAR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 3.750000 Saudi riyal</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>SAR</targetCurrency>
    <exchangeRate>3.750000</exchangeRate>
    </item>
    <item>
    <title>1 USD = 2,392.498301 UZS</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 2,392.498301 Uzbekistan Sum</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>UZS</targetCurrency>
    <exchangeRate>2,392.498301</exchangeRate>
    </item>
    <item>
    <title>1 USD = 245.843766 HUF</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 245.843766 Hungarian forint</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>HUF</targetCurrency>
    <exchangeRate>245.843766</exchangeRate>
    </item>
    <item>
    <title>1 USD = 2.659857 XCD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 2.659857 East Caribbean Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>XCD</targetCurrency>
    <exchangeRate>2.659857</exchangeRate>
    </item>
    <item>
    <title>1 USD = 6.344251 TTD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 6.344251 Trinidad Tobago Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>TTD</targetCurrency>
    <exchangeRate>6.344251</exchangeRate>
    </item>
    <item>
    <title>1 USD = 0.290650 KWD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 0.290650 Kuwaiti dinar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>KWD</targetCurrency>
    <exchangeRate>0.290650</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1,031.768131 MMK</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1,031.768131 Myanma Kyat</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>MMK</targetCurrency>
    <exchangeRate>1,031.768131</exchangeRate>
    </item>
    <item>
    <title>1 USD = 6.155565 HRK</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 6.155565 Croatian Kuna</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>HRK</targetCurrency>
    <exchangeRate>6.155565</exchangeRate>
    </item>
    <item>
    <title>1 USD = 0.384500 OMR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 0.384500 Omani rial</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>OMR</targetCurrency>
    <exchangeRate>0.384500</exchangeRate>
    </item>
    <item>
    <title>1 USD = 10,820.004786 BYR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 10,820.004786 Belarussian Ruble</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>BYR</targetCurrency>
    <exchangeRate>10,820.004786</exchangeRate>
    </item>
    <item>
    <title>1 USD = 8.507888 ARS</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 8.507888 Argentine Peso</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>ARS</targetCurrency>
    <exchangeRate>8.507888</exchangeRate>
    </item>
    <item>
    <title>1 USD = 11.220644 ZAR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 11.220644 South African rand</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>ZAR</targetCurrency>
    <exchangeRate>11.220644</exchangeRate>
    </item>
    <item>
    <title>1 USD = 61.527252 INR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 61.527252 Indian rupee</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>INR</targetCurrency>
    <exchangeRate>61.527252</exchangeRate>
    </item>
    <item>
    <title>1 USD = 3.216094 GHS</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 3.216094 Ghanaian Cedi</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>GHS</targetCurrency>
    <exchangeRate>3.216094</exchangeRate>
    </item>
    <item>
    <title>1 USD = 3.672620 AED</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 3.672620 U.A.E Dirham</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>AED</targetCurrency>
    <exchangeRate>3.672620</exchangeRate>
    </item>
    <item>
    <title>1 USD = 3.336315 MYR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 3.336315 Malaysian ringgit</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>MYR</targetCurrency>
    <exchangeRate>3.336315</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.000000 PAB</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.000000 Panamanian Balboa</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>PAB</targetCurrency>
    <exchangeRate>1.000000</exchangeRate>
    </item>
    <item>
    <title>1 USD = 2.575313 BRL</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 2.575313 Brazilian Real</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>BRL</targetCurrency>
    <exchangeRate>2.575313</exchangeRate>
    </item>
    <item>
    <title>1 USD = 3.393784 PLN</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 3.393784 Polish zloty</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>PLN</targetCurrency>
    <exchangeRate>3.393784</exchangeRate>
    </item>
    <item>
    <title>1 USD = 14.991306 MDL</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 14.991306 Moldova Lei</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>MDL</targetCurrency>
    <exchangeRate>14.991306</exchangeRate>
    </item>
    <item>
    <title>1 USD = 6.128061 CNY</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 6.128061 Chinese yuan</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>CNY</targetCurrency>
    <exchangeRate>6.128061</exchangeRate>
    </item>
    <item>
    <title>1 USD = 525.680853 XAF</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 525.680853 CFA Franc</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>XAF</targetCurrency>
    <exchangeRate>525.680853</exchangeRate>
    </item>
    <item>
    <title>1 USD = 7.420665 SEK</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 7.420665 Swedish krona</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>SEK</targetCurrency>
    <exchangeRate>7.420665</exchangeRate>
    </item>
    <item>
    <title>1 USD = 3.813784 ILS</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 3.813784 Israeli new sheqel</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>ILS</targetCurrency>
    <exchangeRate>3.813784</exchangeRate>
    </item>
    <item>
    <title>1 USD = 21.249688 HNL</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 21.249688 Honduran Lempira</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>HNL</targetCurrency>
    <exchangeRate>21.249688</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.570163 BGN</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.570163 Bulgarian Lev</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>BGN</targetCurrency>
    <exchangeRate>1.570163</exchangeRate>
    </item>
    <item>
    <title>1 USD = 98.420000 NPR</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 98.420000 Nepalese rupee</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>NPR</targetCurrency>
    <exchangeRate>98.420000</exchangeRate>
    </item>
    <item>
    <title>1 USD = 96.591079 RSD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 96.591079 Serbian Dinar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>RSD</targetCurrency>
    <exchangeRate>96.591079</exchangeRate>
    </item>
    <item>
    <title>1 USD = 13.589492 MXN</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 13.589492 Mexican Peso</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>MXN</targetCurrency>
    <exchangeRate>13.589492</exchangeRate>
    </item>
    <item>
    <title>1 USD = 46.551394 RUB</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 46.551394 Russian rouble</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>RUB</targetCurrency>
    <exchangeRate>46.551394</exchangeRate>
    </item>
    <item>
    <title>1 USD = 5.191002 TJS</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 5.191002 Tajikistan Ruble</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>TJS</targetCurrency>
    <exchangeRate>5.191002</exchangeRate>
    </item>
    <item>
    <title>1 USD = 5.974286 DKK</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 5.974286 Danish krone</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>DKK</targetCurrency>
    <exchangeRate>5.974286</exchangeRate>
    </item>
    <item>
    <title>1 USD = 2,137.372829 COP</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 2,137.372829 Colombian peso</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>COP</targetCurrency>
    <exchangeRate>2,137.372829</exchangeRate>
    </item>
    <item>
    <title>1 USD = 32.807189 THB</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 32.807189 Thai baht</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>THB</targetCurrency>
    <exchangeRate>32.807189</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1,093.707339 KRW</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1,093.707339 South Korean Won</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>KRW</targetCurrency>
    <exchangeRate>1,093.707339</exchangeRate>
    </item>
    <item>
    <title>1 USD = 8.852911 MAD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 8.852911 Moroccan Dirham</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>MAD</targetCurrency>
    <exchangeRate>8.852911</exchangeRate>
    </item>
    <item>
    <title>1 USD = 3.556292 RON</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 3.556292 Romanian New Leu</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>RON</targetCurrency>
    <exchangeRate>3.556292</exchangeRate>
    </item>
    <item>
    <title>1 USD = 6.788412 NOK</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 6.788412 Norwegian krone</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>NOK</targetCurrency>
    <exchangeRate>6.788412</exchangeRate>
    </item>
    <item>
    <title>1 USD = 416.098767 AMD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 416.098767 Armenia Dram</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>AMD</targetCurrency>
    <exchangeRate>416.098767</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.292300 BND</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.292300 Brunei dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>BND</targetCurrency>
    <exchangeRate>1.292300</exchangeRate>
    </item>
    <item>
    <title>1 USD = 30.606834 TWD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 30.606834 New Taiwan Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>TWD</targetCurrency>
    <exchangeRate>30.606834</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.291521 SGD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.291521 Singapore dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>SGD</targetCurrency>
    <exchangeRate>1.291521</exchangeRate>
    </item>
    <item>
    <title>1 USD = 15.849986 UAH</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 15.849986 Ukrainian Hryvnia</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>UAH</targetCurrency>
    <exchangeRate>15.849986</exchangeRate>
    </item>
    <item>
    <title>1 USD = 124.032775 ISK</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 124.032775 Icelandic krona</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>ISK</targetCurrency>
    <exchangeRate>124.032775</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.933833 FJD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.933833 Fiji Dollar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>FJD</targetCurrency>
    <exchangeRate>1.933833</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.834686 TND</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.834686 Tunisian dinar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>TND</targetCurrency>
    <exchangeRate>1.834686</exchangeRate>
    </item>
    <item>
    <title>1 USD = 1.932400 LYD</title>
    <link>http://www.floatrates.com/currency?USD</link&gt;
    <description>1 U.S. Dollar = 1.932400 Libyan dinar</description>
    <pubDate>Fri, 14 Nov 2014 00:00:01 GMT</pubDate>
    <baseCurrency>USD</baseCurrency>
    <targetCurrency>LYD</targetCurrency>
    <exchangeRate>1.932400</exchangeRate>
    </item>
    </channel>
  • MagnoMagno Posts: 168Member
    It looks like you are trying to get a nodelist of item/title, except that is an element.

    XMLNodes := XMLDoc.getElementsByTagName('item/title');

    After that you select a subitem 'title'

    codCurrency := XMLNode.selectNodes('title').item(0).text;

    But underneath title, there is not another element title.

    I think in your case, you need to get ElementsByTagName('item') only

    basically changing your code to this:
    CLEAR(XMLHTTP);
    CREATE(XMLHTTP,TRUE,TRUE);
    
    
    XMLHTTP.open('POST','http://www.floatrates.com/daily/USD.xml',0);
    XMLHTTP.setRequestHeader('Content-type','text/xml');
    XMLHTTP.send('');
    
    CLEAR(XMLDoc);
    CREATE(XMLDoc,TRUE,TRUE);
    
    XMLDoc.load(XMLHTTP.responseXML);
    
    XMLNodes := XMLDoc.getElementsByTagName('item');
    XMLNode := XMLNodes.item(0);
    WHILE NOT ISCLEAR(XMLNode) DO BEGIN
    codCurrency := XMLNode.selectNodes('title').item(0).text;
    MESSAGE('%1',codCurrency);
    END;
    

    regards,
    Magno
    There are no bugs, only random undocumented features...
    ---
    My Blog: http://NAV-Magno.be
  • JaanuJaanu Posts: 44Member
    Hi Magno,

    Thank for your reply. But when i try your code, RTC get hang and there is no results.
  • rehansattirehansatti Posts: 36Member
    Hi @Jaanu , The solution of the above issue is simple. You need to understand the conceptual model of XAML file.
    1) Get the response and Assign to DOMDocument. This DomDocument object has all the data you have shared on the feedback of your XML File.
    2) Identify the Item by its tag name.
    3) Assign that to XMLDOMNodeList.
    4) Use the Do while loop to iterate the Items in the list.
    The above code is hanging because there is no Do while loop termination condition.

    Have a look in to the following simple solution:)
    " DOMDocument.load(WinHTTP.responseXML);
    CLEAR(WinHTTP);

    IXMLDOMNodeList := DOMDocument.getElementsByTagName('item');
    IXMLDOMNode := IXMLDOMNodeList.item(0);
    WHILE NOT ISCLEAR(IXMLDOMNode) DO BEGIN

    TempExchRate.INIT;
    TempExchRate."Starting Date" := TODAY;//ToDate(IXMLDOMNode.selectNodes('pubDate').item(0).text);
    TempExchRate."Currency Code" := IXMLDOMNode.selectNodes('targetCurrency').item(0).text;
    TempExchRate."Relational Currency Code" := '';
    TempExchRate."Exchange Rate Amount" := ToDecimal( IXMLDOMNode.selectNodes('exchangeRate').item(0).text);;
    TempExchRate."Relational Exch. Rate Amount" := 1;
    TempExchRate."Adjustment Exch. Rate Amount" := ToDecimal( IXMLDOMNode.selectNodes('exchangeRate').item(0).text);
    TempExchRate."Relational Adjmt Exch Rate Amt" := 1;
    TempExchRate."Fix Exchange Rate Amount" := TempExchRate."Fix Exchange Rate Amount"::"Relational Currency";
    IF NOT TempExchRate.INSERT(TRUE) THEN;

    IXMLDOMNode := IXMLDOMNodeList.nextNode;(THis was missing in the above code shared)
    END;"
    I have not parsed date yet. So assigning the current date.
    Best Regards
    Rehan Satti
    Microsoft Dynamics NAV Technical Consultant
    Please verify the answer if it satisfy your question. This will help other members of community.
Sign In or Register to comment.