loop xml nodes?
Posted: Wed Sep 09, 2020 10:12 am
I have this XML. How can I loop the XML and get all values in <code>?
My code. I get the first log from nodeList but not my second log "code".
Expected result in log
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<Orders>
<Order>
<Product>
<Line_Id>1</Line_Id>
<Product_Id>9831</Product_Id>
<Name>Pontus</Name>
<Qty>1</Qty>
<code>AAAAA</code>
</Product>
<Product>
<Line_Id>2</Line_Id>
<Product_Id>9831</Product_Id>
<Name>Pontus</Name>
<Qty>1</Qty>
<code>BBBBB</code>
</Product>
</Order>
</Orders>
Code: Select all
var dataset = job.getDataset("Xml");
var xml = new Document(dataset.getPath());
var nodeList = xml.evalToNodes("/Orders/Order/Products/Product");
s.log(1, "Found: " + nodeList.length); //This works
for(var i = 1; i < nodeList.length + 1; i++){
var node = nodeList.at(i);
var code = node.getValue(); //This is not working
s.log(1, code);
}
I don't get any suggestions when I write a dot (.) after "node" and get the error getValue(); is not a function.AAAAA
BBBBB