Skip to main content
sreekarthikeyank
Known Participant
February 10, 2020
Answered

Read XML

  • February 10, 2020
  • 1 reply
  • 1468 views

How to read the attribute values in the below xml file.  

 

<List>
<p name="DZPNumber" replacement="PN"/>
<p name="DZPTitle" replacement="PT"/>

</List>

 

var myXMLFile = File("/WorkSpace//Collection.xml")

myXMLFile.open('r');

var allElements = new XML(myXMLFile.read());

myXMLFile.close();

var nodes = allElements[0].xpath("//p");

for(var i = 0; i < nodes.length(); i++){

      $.writeln (nodes[i])

}

This topic has been closed for replies.
Correct answer Manan Joshi

Use the @notation like follows

nodes[i].@name

 

-Manan

1 reply

Manan JoshiCommunity ExpertCorrect answer
Community Expert
February 10, 2020

Use the @notation like follows

nodes[i].@name

 

-Manan

-Manan