XML Responses and AJAX - A Quick look at XMLDOM
(Page 4 of 5 )
In this section we look at the parsing of the XML document in some detail. The responseXML is an XML document, and its properties can also be accessed.
responseXML's basic properties
document.getElementById("x4").innerHTML=xhr.responseXML.
firstChild.nodeName
document.getElementById("x5").innerHTML=xhr.responseXML.
lastChild.nodeName
Displayed result for the above snippet
xml
wclassRelevant portion of the XML Document

responseXML.documentElement's basic properties
document.getElementById("x2").innerHTML= xhr.responseXML.documentElement.firstChild.nodeName
document.getElementById("x3").innerHTML= xhr.responseXML.documentElement.lastChild.nodeName
Displayed result for the above snippet
The responseXML is considered as a document with root wclass. The boundary is the document. The first child is comment and the lastChild is student.
#comment
student
Relevant portion of the XML Document
documentElement's children
In this case, it is the responseXML document's children. Let's take the example of item 3. The following snippet captures this child's properties.
document.getElementById("x6").innerHTML= xhr.responseXML.documentElement.childNodes.item(3).text
document.getElementById("x7").innerHTML= xhr.responseXML.documentElement.childNodes.item(3).
attributes[0].name
document.getElementById("x8").innerHTML=
attributes[0].value
Displayed result for the above snippet
Charles Boyer HTML, Photoshop
id
3
Relevant portion of the XML Document

Next: Student Nodes Collection >>
More XML Articles
More By Jayaram Krishnaswamy