XML
  Home arrow XML arrow Page 2 - Roaming through XMLDOM: An AJAX Prerequisi...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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

Roaming through XMLDOM: An AJAX Prerequisite
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    2006-02-20

    Table of Contents:
  • Roaming through XMLDOM: An AJAX Prerequisite
  • Getting at the Innards of an XML Document
  • Continuing the Dissection
  • Manipulating the 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


    Roaming through XMLDOM: An AJAX Prerequisite - Getting at the Innards of an XML Document


    (Page 2 of 4 )

    We will briefly look at some of the XML Dom objects. In order to show how the code accesses the various parts of a document, consider the following well formed XML document WebClass.xml which is located on my hard drive at:

    C:/Documents and settings/computer user/Desktop/todo/Ajax/WebClass.xml.

    XML document probed

    <?xml version="1.0" encoding="ISO-8859-1" ?> 
    <wclass>
    <!-- My students who attended my web programming class -->
    <student id="1">
    <name>Linda Jones</name> 
    <legacySkill>Access, VB5.0</legacySkill>
    </student>
    <student id="2">
    <name>Adam Davidson</name> 
    <legacySkill>Cobol, MainFrame</legacySkill>
    </student>
    <student id="3">
    <name>Charles Boyer</name> 
    <legacySkill>HTML, Photoshop</legacySkill>
    </student>
    <student id="4">
    <name>Charles Mann</name> 
    <legacySkill>Cobol, MainFrame</legacySkill>
    </student>
    </wclass>
    

    Slicing the XML document

    First things first: we need to instantiate an XMLDocument object. This is done easily by running the following code as shown:

    <SCRIPT LANGUAGE="JavaScript">
    var xml_doc = new ActiveXObject("Microsoft.XMLDOM"); 
    xml_doc.async = false; 
    xml_doc.load ("C:/Documents and settings/computer user/Desktop/
    todo/Ajax/WebClass.xml"); </SCRIPT>

    After this step we will look at a number of properities that can be accessed using code.

    First Child and Last Child Properties

    These properties can be accessed if you insert the following lines after loading the document as shown above but before </Script>,

    document.write ("This documents first child is a " + 
    xml_doc.documentElement.firstChild.nodeName);
    document.write("<br>");
    document.write ("This document's  last child= " + 
    xml_doc.documentElement.lastChild.nodeName);
    

    and if you display it in a browser you would see the following:

    This documents first child is a #comment
    This document's last child= student

    XML ARTICLES

    - 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
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek