XML
  Home arrow XML arrow Page 3 - Introduction to XML Document Object Model
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Introduction to XML Document Object Model
By: Gayathri Gokul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 15
    2004-02-09

    Table of Contents:
  • Introduction to XML Document Object Model
  • Covering Our Base
  • DOM Simplified
  • Working With XML Data
  • Traversing the Nodes in an XML Document

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introduction to XML Document Object Model - DOM Simplified


    (Page 3 of 5 )

    DOM Simplified

    Now let us look at the node structure of our XML document with little more detail. We will examine one side of the document structure alone for ease of explanation.  All this applies to the other side as well.

    XML DOM

    Here in Figure1, you can clearly see how you can use these properties to navigate around the XML DOM. The lines indicate which nodes the properties point to. The children on the root node, BookAuthor, are held in the childNode collection. In the above case BookAuthor only has one child, so both its firstChild and its lastChild properties point to the same node. In the above case which we are discussing, childNode(0 will apply. Since it is the only node in the collection.

    The Author node however, has three children, held in a childNodes collection. The pointer to the au_id is that of firstChild property, which is the same as childNodes(0), and the lastchild property points to au_fname node. The previousSibling and nextSibling properties point to the next node collection at the same level.
    So let us assume we have a node named baRoot pointing to BookAuthors, the following table helps demonstrate the parent-child hierarchy.

    CodePoints To
    baRoot.childNodes(0)Author
    baRoot.childNodes(0).firstChildau_id
    baRoot.childNodes(0).firstChild.nextSiblingau_lname
    baRoot.childNodes(0).firstChild.parentNodeAuthor
    baRoot.childNodes(0).firstChild.nextSibling.parentNodeAuthor

    Specific DOM Objects

    XML, was designed to be eXtensible, data integration and data exchange is one of its key features. XML was anchored to cater to a tremendous variety of documents. Despite this there are no specific objects for different types of node. Really, what makes it so intriguing is that, they inherit most of the properties and methods of the Node objects as well as adding specific methods and properties relevant to the particular node type. The following table lists the specific DOM Objects:

    ObjectDescription
    DocumentThe root object for an XML document.
    DocumentTypeStores info about DTD or Schema associated with the XML document.[For e.g. !DOCTYPE in a DTD]
    DocumentFragment A lightweight copy of the document. Useful for temporary storage or document insertions.
    ElementAn XML element.
    Attribute or AttrAn XML attribute.
    EntityA parsed or unparsed entity.[E.g. !ENTITY in a DTD.]
    EntityReferenceAn XML entity reference.
    NotationA notation.[e.g.!NOTATION in DTD]
    CharacterDataThe base object for text information in an XML document.
    CDATASectionUnparsed character data (e.g. !CDATA in DTD) .
    TextThe text content of an element or attribute node.
    CommentAn XML comment element.
    ProcessingInstructionA processing instruction as held in <?   ?> section
    ImplementationApplication specific implementation details.

    More XML Articles
    More By Gayathri Gokul


     

    XML ARTICLES

    - More on Triggers and Styles and Control Temp...
    - Looking at Triggers with Styles and Control ...
    - A Closer Look at Styles and Control Templates
    - Styles and Control Templates
    - Properties and More in XAML
    - Elements and Attributes in XAML
    - XAML in a Nutshell
    - Importing XML Files into Access 2007
    - Using MSXML3.0 with VB 6.0
    - MSXML, concluded
    - MSXML, continued
    - MSXML Tutorial
    - Generating XML Schema Dynamically Using VB.N...
    - XSL Transformations using ASP.NET
    - Applying XSLT to XML Using ASP.NET





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT