CFXML: Probing XMLDOM in ColdFusion
(Page 1 of 5 )
This tutorial examines how to access the individual elements of an XML document in ColdFusion, if you have a reference to that document. Two ways to access the individual elements are demonstrated.
Introduction
Following the enormous success of AJAX, there has been a great deal of activity in probing the XMLDOM. In an earlier tutorial, accessing the XMLDOM using Javascript/ECMAScript was described. For an example XML file, a complete analysis of accessing the individual parts was presented using the DOM's structure.
If you have a reference to an XML document, how do you access individual elements in ColdFusion? Well, this tutorial looks at this question using the same example file used in the previous tutorials. This tutorial shows two ways to access the individual elements of the XMLDOM object, referenced as an object and as a structured file. Also available are third party tools that do the XML parsing.
The example XML FileThe xml file used in this tutorial, webstudents.xml, has a simple structure. It represents students taking a web programming class, with some information about their skills as shown below. It is a well formed XML file and does not have a schema, or a DTD. It is assumed that the example file is in a virtual directory and that the IIS server has been configured for the CF MX Server.
<?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>
Next: Create a ColdFusion Object Using the Microsoft.XMLDOM Class >>
More ColdFusion Articles
More By Jayaram Krishnaswamy