The XML DOM Objects

Here are the official W3C DOM Level 1 objects:

  • Document The document object.

  • DocumentFragment A fragment of a document.

  • DocumentType Reference to the <!DOCTYPE> element.

  • EntityReference Reference to an entity.

  • Element An element.

  • Attr An attribute.

  • ProcessingInstruction A processing instruction.

  • Comment The content of an XML comment.

  • Text Text content of an element or attribute.

  • CDATASection Refers to CDATA section

  • Entity Stands for a parsed or unparsed entity in the XML document.

  • Notation Holds a notation.

  • Node A single node in the document tree.

  • NodeList A list of node objects. Allows iteration and indexed access operations.

  • NamedNodeMap Allows iteration and access by name to the collection of attributes.

Microsoft uses different names for these objects and adds its own. In particular, Microsoft defines a set of "base objects" that form the foundation of its XML DOM. The top-level object is the DOMDocument object, and it's the only one you create directlyyou reach the other objects through that object. Here's the list of base objects in Internet Explorer. Note the objects designed to treat a document as a tree of nodes XMLDOMNode , XMLDOMNodeList , and so on:

  • DOMDocument The top node of the XML DOM tree.

  • XMLDOMNode A single node in the document tree. Includes support for data types, namespaces, DTDs, and XML schemas.

  • XMLDOMNodeList A list of node objects. Allows iteration and indexed access operations.

  • XMLDOMNamedNodeMap Object that allows iteration and access by name to the collection of attributes.

  • XMLDOMParseError Information about the most recent error. Includes error number, line number, character position, and a text description.

  • XMLHttpRequest Object that allows communication with HTTP servers.

  • XSLRuntime Object that supports methods that you can call from XSL stylesheets.

Besides these base objects, the Microsoft XML DOM provides these XML DOM objects that you use when working with documents in code. This includes the various types of nodes, which you see supported with objects of types such as XMLDOMAttribute , XMLDOMCharacterData , and XMLDOMElement :

  • XMLDOMAttribute Stands for an attribute object

  • XMLDOMCDATASection Handles CDATA sections so that text is not interpreted as markup language

  • XMLDOMCharacterData Provides methods used for text manipulation

  • XMLDOMComment Provides the content of an XML comment

  • XMLDOMDocumentFragment Is a lightweight object useful for tree insert operations

  • XMLDOMDocumentType Holds information connected to the document type declaration

  • XMLDOMElement Stands for the element object

  • XMLDOMEntity Stands for a parsed or unparsed entity in the XML document

  • XMLDOMEntityReference Stands for an entity reference node

  • XMLDOMImplementation Supports general DOM methods

  • XMLDOMNotation Holds a notation (as declared in the DTD or schema)

  • XMLDOMProcessingInstruction Is a processing instruction

  • XMLDOMText Provides text content of an element or attribute

We'll put many of these objects to work in this chapter, seeing how to parse and access XML documents using the Microsoft XML DOM and handling events as documents are loaded. We'll also see how to alter an XML document at run time.

The previous list of objects is pretty substantial, and each object can contain its own properties, methods, and events. Although most of these properties, methods, and events are specified in the W3C XML DOM, many are added by Microsoft as well. If we're going to work with the XML DOM in practice, it's essential to have a good understanding of these objects, both practically for the purposes of this chapter and for reference. I'll go through the major objects in some detail to make handling the XML DOM clear, starting with the main object, the DOMDocument object.



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net