Aaron Longnion
-----Original Message-----
From: Suyer, Ed [PRD Non-J&J] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 20, 2003 10:05 AM
To: '[EMAIL PROTECTED]'
Subject: RE: [cf-xml] Retrieving Root attributeHey Ken,Here's the CF code you'll need. Not sure if all of this is available in CF5 ... I use this with CFMX:<!--- read and parse xml file into cf structure ---><cffile action="" file="myxmlfile.xml" variable="xmldoc">
<cfset mydoc = XmlParse(xmldoc)><!--- at this point mydoc is a cf structure that contains properties for each element in the xml doc. the following command let's you view this struc in mx. In cf5, you'll probobally need to use the structure functions to debug ref: http://localhost/cfdocs/CFML_Reference/functions-pt020.html#1099964 ---><cfdump var="#mydoc#"><!--- the following is one way to then extract xml elements into cf variables --->local.createddate = mydoc.XmlRoot.type.XmlText;<!--- also, here's a way to loop through your row elements and fields ---><cfloop index="i" from="1" to="#ArrayLen(mydoc.XmlRoot.XmlChildren)#">
<!--- parse ea element for argument names and bind --->
<cfset local.fieldvalue = mydoc.XmlRoot.XmlChildren[i].XmlText>
</cfloop>Hope this helps.Best regards,Ed.-----Original Message-----
From: Thomason, Ken L. [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 19, 2003 2:50 PM
To: '[EMAIL PROTECTED]'
Subject: [cf-xml] Retrieving Root attribute
I am relatively new to XML and the XML Toolkit. I am currently able to retrieve elements from an XML structure I am working with but I am not sure how to retrieve an attribute of the ROOT node.
For example this is a snippet of the XML file I am working with:
<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE ROOT (View Source for full doctype...)>
- <ROOT DATE_CREATED="2003-02-19 19:05:23" CREATED_BY="Microsoft Log Parser V2.0">
- <ROW>
<Field1>Field 1</Field1>
<Field2>Field 2</Field2>
<Field3>Field 3</Field3>
</ROW>
</ROOT>I would like to be able to retrieve the DATE_CREATED attribute for the XML document.
As you can see the XML doc is created by Microsoft's Log Parser and I am using the XML toolkit with Cold Fusion 5.Thanks in advance for you help,
Ken
