How to use XML DOM Node List

In this article I am going to explain about XML DOM Node List.
  • 2292

XML DOM Node list

In XML DOM list object represent list of node in the same form as the XML document. Node list object contain collection of node that is access from index number. Index number starts from 0 index. A node list object keep it-self Updated. It means as soon as element is change in XML document then list will be automatically changed according to change document.

Example

Following example return list of "Name" element in "Detail.xml".

Doce=loadXMLDoc("Detail.xml");

 str=Doce.getElementsByTagName("Name");

Node list Length

Node list return number of node in the list.

Following example will return number of "Name" element in "Detail.xml" and Display the each node value.

Doce=loadXMLDoc("Detail.xml");

str=Doce.getElementsByTagName('Name');

for (i=0;i<str.length;i++)

{

document.write(str[i].childNodes[0].nodeValue);

document.write("<br />");

}

DOM attribute list

Attribute properties of  node represent list of attribute node of in XML document. When we add, delete, modify to any attribute then attribute list automatically changed according to XML document.

Following example will display "person" attribute.

Doce=loadXMLDoc("Detail.xml");

x=xmlDoc.getElementsByTagName("cate")[0].attributes;

document.write(str.getNamedItem("person").nodeValue);

 

You may also want to read these related articles: here
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

 

© 2019 DotNetHeaven. All rights reserved.