The twin tasks of the XMLHttp are handling the HTTP request, and then processing the XML response. The first one is easily done by writing the appropriate syntax for creating this object. This is what is accomplished in AJAX by invoking the new constructor for XMLHTTP object. This is but one of the objects of the XMLDOM -XML Document Object Model. In this article, we look at XMLDOM in some detail before calling the XML document in an AJAX rendition in a future article.
Roaming through XMLDOM: An AJAX Prerequisite (Page 1 of 4 )
A quick look at XMLDOM
The DOM of HTML and XMLDOM share some common traits. The basic precept that documents are hierarchically structured with nodes and nested nodes is common to both of them. The DOM object model as seen in W3C documentation is described in full here.
XMLDOM can be understood through two types of metaphors, a tree representation and a family representation. In the tree representation, the tree has nodes. Nodes can have other nodes growing out of them, or a node can stand by itself without any other nodes sprouting from it. In the family metaphor you have parents, children, siblings, and so on.
Accessing XML via XMLDOM is facilitated by ActiveX. All that is needed is to create a new ActiveXObject, via the call:
var xml_doc=new ActiveXObject ("Microsoft.XMLDOM");
Once this is created, an XML document from a given location can be loaded. Then we can look at the various properties of this object as detailed in the XMLDOM. The following listing gives a brief description of the XMLDOM objects that are well suited for client side scripting.
In XMLDOM as well as HTML's DOM the following interfaces are used for accessing. In the present tutorial we will only look at a subset of the properties and methods of the highlighted objects.
Attr
CharacterData
Comment
DocumentFragment
Document
DOMException
DOMImplementation
Element
Node
NodeList
NamedNodeMap
Text
Document
Document is the root of the XML document.
Element
The element object represents the Document's various elements, such as root and other elements.
Node
"Node" is a single node in the document tree representation. This has support for data types, namespaces, DTDs and XML Schemas.
Attribute
"Attribute" represents the single attribute node of an element.
Text
"Text" represents the text of an element or attribute.