Home arrow XML arrow Page 4 - XML Responses and AJAX
XML

XML Responses and AJAX


In a previous tutorial we looked at the responseText property of the XMLHTTP Request. This tutorial will focus on the responseXML accessor.

Author Info:
By: Jayaram Krishnaswamy
Rating: 4 stars4 stars4 stars4 stars4 stars / 40
February 27, 2006
TABLE OF CONTENTS:
  1. · XML Responses and AJAX
  2. · A brief explanation of innerHTML
  3. · AJAX returning an XML document
  4. · A Quick look at XMLDOM
  5. · Student Nodes Collection

print this article
SEARCH DEVARTICLES

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
wclass

Relevant 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



blog comments powered by Disqus
XML ARTICLES

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials