How to read an XML using java script
Load the XML first.
In Explorer:
To read a child element's value
var ChildVal= request.responseXML.childNodes(1).firstChild.text; where childVal will give you the Child element value.To read the attribute of a child element use var chdAttr = request.responseXML.childNodes(1).getAttribute("ATTRIBUTE NAME"); where chdAttr returns first child's Attribute value.
In Mozilla Browser
To read a child element's value
var ChildVal= request.responseXML.getElementsByTagName("CHILDNAME")[0].firstChild.nodeValue; where childVal will give you the Child element value.To read the attribute of a child element use var chdAttr =request.responseXML.getElementsByTagName("CHILDNAME")[0].getAttribute("ATTRIBUTE NAME"); where chdAttr returns first child's Attribute value.
In Explorer:
To read a child element's value
var ChildVal= request.responseXML.childNodes(1).firstChild.text; where childVal will give you the Child element value.To read the attribute of a child element use var chdAttr = request.responseXML.childNodes(1).getAttribute("ATTRIBUTE NAME"); where chdAttr returns first child's Attribute value.
In Mozilla Browser
To read a child element's value
var ChildVal= request.responseXML.getElementsByTagName("CHILDNAME")[0].firstChild.nodeValue; where childVal will give you the Child element value.To read the attribute of a child element use var chdAttr =request.responseXML.getElementsByTagName("CHILDNAME")[0].getAttribute("ATTRIBUTE NAME"); where chdAttr returns first child's Attribute value.