Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Suitescript中解析XML时出现问题_Xml_Suitescript - Fatal编程技术网

在Suitescript中解析XML时出现问题

在Suitescript中解析XML时出现问题,xml,suitescript,Xml,Suitescript,以下是我试图解析的XML: <?xml version="1.0" encoding="UTF-8"?> <DataSet xmlns="http://www.bnr.ro/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bnr.ro/xsd nbrfxrates.xsd"> <Header> <Pu

以下是我试图解析的XML:

<?xml version="1.0" encoding="UTF-8"?>
<DataSet xmlns="http://www.bnr.ro/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bnr.ro/xsd nbrfxrates.xsd">
    <Header>
        <Publisher>National Bank of Romania</Publisher>
        <PublishingDate>2017-01-18</PublishingDate>
        <MessageType>DR</MessageType>
    </Header>
    <Body>
        <Subject>Reference rates</Subject>
        <OrigCurrency>RON</OrigCurrency>
        <Cube date="2017-01-18">
            <Rate currency="AED">1.1462</Rate>
            <Rate currency="AUD">3.1789</Rate>
            <Rate currency="BGN">2.2998</Rate>
            <Rate currency="BRL">1.3109</Rate>
            <Rate currency="CAD">3.2177</Rate>
            <Rate currency="CHF">4.1982</Rate>
            <Rate currency="CNY">0.6156</Rate>
            <Rate currency="CZK">0.1665</Rate>
            <Rate currency="DKK">0.6049</Rate>
            <Rate currency="EGP">0.2230</Rate>
            <Rate currency="EUR">4.4980</Rate>
            <Rate currency="GBP">5.1802</Rate>
            <Rate currency="HRK">0.5971</Rate>
            <Rate currency="HUF" multiplier="100">1.4598</Rate>
            <Rate currency="INR">0.0619</Rate>
            <Rate currency="JPY" multiplier="100">3.7123</Rate>
            <Rate currency="KRW" multiplier="100">0.3598</Rate>
            <Rate currency="MDL">0.2084</Rate>
            <Rate currency="MXN">0.1943</Rate>
            <Rate currency="NOK">0.4976</Rate>
            <Rate currency="NZD">3.0325</Rate>
            <Rate currency="PLN">1.0276</Rate>
            <Rate currency="RSD">0.0363</Rate>
            <Rate currency="RUB">0.0711</Rate>
            <Rate currency="SEK">0.4721</Rate>
            <Rate currency="TRY">1.1122</Rate>
            <Rate currency="UAH">0.1531</Rate>
            <Rate currency="USD">4.2098</Rate>
            <Rate currency="XAU">164.0436</Rate>
            <Rate currency="XDR">5.7050</Rate>
            <Rate currency="ZAR">0.3098</Rate>
        </Cube>
    </Body>
</DataSet>
我在调试器中得到的结果:

warning ZAR [#text: 0.3098] null    18/1/2017 23:52:47.416
warning XDR [#text: 5.7050] null    18/1/2017 23:52:47.416
warning XAU [#text: 164.0436] null  18/1/2017 23:52:47.416
warning USD [#text: 4.2098] null    18/1/2017 23:52:47.416
warning UAH [#text: 0.1531] null    18/1/2017 23:52:47.416
warning TRY [#text: 1.1122] null    18/1/2017 23:52:47.416
warning SEK [#text: 0.4721] null    18/1/2017 23:52:47.416
warning RUB [#text: 0.0711] null    18/1/2017 23:52:47.416
warning RSD [#text: 0.0363] null    18/1/2017 23:52:47.416
warning PLN [#text: 1.0276] null    18/1/2017 23:52:47.416
warning NZD [#text: 3.0325] null    18/1/2017 23:52:47.416
warning NOK [#text: 0.4976] null    18/1/2017 23:52:47.416
warning MXN [#text: 0.1943] null    18/1/2017 23:52:47.416
warning MDL [#text: 0.2084] null    18/1/2017 23:52:47.416
warning KRW [#text: 0.3598] 100 18/1/2017 23:52:47.416
warning JPY [#text: 3.7123] 100 18/1/2017 23:52:47.416
warning INR [#text: 0.0619] null    18/1/2017 23:52:47.416
warning HUF [#text: 1.4598] 100 18/1/2017 23:52:47.416
warning HRK [#text: 0.5971] null    18/1/2017 23:52:47.416
warning GBP [#text: 5.1802] null    18/1/2017 23:52:47.416
warning EUR [#text: 4.4980] null    18/1/2017 23:52:47.416
warning EGP [#text: 0.2230] null    18/1/2017 23:52:47.416
warning DKK [#text: 0.6049] null    18/1/2017 23:52:47.416
warning CZK [#text: 0.1665] null    18/1/2017 23:52:47.416
warning CNY [#text: 0.6156] null    18/1/2017 23:52:47.416
warning CHF [#text: 4.1982] null    18/1/2017 23:52:47.416
warning CAD [#text: 3.2177] null    18/1/2017 23:52:47.416
warning BRL [#text: 1.3109] null    18/1/2017 23:52:47.416
warning BGN [#text: 2.2998] null    18/1/2017 23:52:47.416
warning AUD [#text: 3.1789] null    18/1/2017 23:52:47.416
warning AED [#text: 1.1462] null    18/1/2017 23:52:47.415
以下是调试器中“entry”对象的外观:

如果没有[#text:…],我如何获得每种货币的汇率,以及为什么文本值采用这种格式。

知道了,我替换了

var currencyRate = nlapiSelectNode(entry, "text()");


我不知道SuiteScript,但我知道XML和xPath。这是一个非常复杂的XPath语句,//rate不起作用吗?RE:Rates,我会尝试替换var currencyRate=nlapiSelectNode(条目“text()”);使用var currencyRate=nlapiSelectValue(输入,“text()”);我试过了,它返回空值:(
var currencyRate = nlapiSelectNode(entry, "text()");
var currencyRate = nlapiSelectNode(entry, "text()").textContent;