CFXML: Probing XMLDOM in ColdFusion - Create a ColdFusion Object Using the Microsoft.XMLDOM Class (Page 2 of 5 )
In this case we will be using ColdFusion's <cfobject..> tag to create a reference to the XMLDOM. According to Macromedia, the <cfobject..> tag can be used to access methods that are related to COM, JAVA, and CORBA of similarly named type objects. For each type there are couple of other attributes, which in the case of type=COM are Action, Class, Name, Context, and Server.
Assuming that we place the webstudents.xml file in a virtual directory on the localhost, we can create an object in ColdFusion using the <cfobject..> tag by using the create method of the tag shown in the following snippet.
Once you have a reference to this object, then accessing the properties will be similar to the way they were accessed in the tutorial Roaming through XMLDOM: an Ajax Prerequisite. I am describing two examples taken as is from the above tutorial modified for ColdFusion. For example the first and lastChild elements are accessed by the following snippet, firstlast.cfm.
This would produce the following display in the browser:
Linda Jones Access, VB5.0
Adam Davidson Cobol, MainFrame
Charles Boyer HTML, Photoshop
Charles Mann Cobol, MainFrame
Accessing an XML file with CF
It is also possible to get a handle on the XML Document using the <Cffile.....> tag. Using this method the XML functions supported by ColdFusion can be used. The following snippet shows how to access the same webstudents.xml file using this method.