Chris asks:
Can CF7 read this type of XML entry? I'm having problems reading it...<Bios name="Phoenix ROM BIOS PLUS Version 1.10 A04" date="(17-May-2004)"/>
So I knew the answer to this was yes, but to be sure, I wrote up a quick test case:
<cfxml variable="test">
<Bios name="Phoenix ROM BIOS PLUS Version 1.10 A04" date="(17-May-2004)"/>
</cfxml>
<cfdump var="#test#">
This dumped the XML just fine, and revealed the hint that Chris probably needed to read the data. The name and date value exist in the xmlAttributes key. So in order to get those specific values (assuming he has already created an XML object called test, as I did above), he could use the following code:
<cfoutput>
Name: #test.bios.xmlAttributes.name#<br/>
Date: #test.bios.xmlAttributes.date#<br/>
</cfoutput>
Archived Comments
I did figure out the xmlattributes later that night.:) This is my first time getting into XML (with or w/o CF + I’m a CF newbie). Thank you for the help!
Also, I love the "Ask a Jedi" postings, it's a great help. Your posting on “CF 101: Config Files a-Go Go” got me looking into XML.
Keep up the great work!
-Chris
Thats interesting. I use XMLAttributes all the time, but not like node.XMLAttributes.attributename, instead I always use node.XMLAttributes["attributeName"]. Just thought I would throw that out there in case you need it. Also there is XMLText, XMLChildren and a couple more that you can use to access different things. Glad to know that way too though.
Ryan, for all structs in CF you can use either x.y or x["y"] - that's not specific to the XML navigation.
Right, I know that, but I wasn't thinking of the xml data as a structure (especially since a lot of things like the xmlchildren return arrays). I thought it was just certain syntax that was needed when working with xml, and it worked so I never really needed to go check it out any more than that.