Today I got a very interesting issue. I was working on some code written by somebody else who is (obviously when running in one of “those” issue) not in the company anymore. It was part of Novasphere, a CMS engine we use at ZeroOne.
When I was trying to set up a new Novasphere instance on a CF 7 box I wondered that some functionalitites didn’t work. My colleague Max and I started debugging it and found that the developer used a .toString() Java function to access the content of ColdFusion XML objects (Important: we’re not talking about the CF function ToString() here). This worked fine on CF 6 but not on CF 7 anymore as I assume Macromedia updated the internal Apache Xerxes engine for XML to a newer version.
Here’s some code:
<cfxml variable="myXML"> <user> <name>Kai Koenig</name> <age>31</age> <skills id="1"> <role>coach</role> <type>training</type> </skills> <skills id="2"> <role>architect</role> <type>development</type> </skills> </user> </cfxml> <cfdump var="#myXML#"> <cfoutput> #myXML.user.toString()# </cfoutput>
On CF6 this creates:
Kai Koenig 31 coach training architect development
On CF7 you’ll end up with:
[user: null]
What’s my point? Always be careful when using undocumented and unofficial stuff!
#toString(myXML.user)# does work with CF7.
Cheers,
~Rob
For what it’s worth, the “correct” way to do this (at least on CF7) is:
#toString(myXML.user)#
Sean, Rob, you’re right. But as mentioned in the post, that’s not what this is about. It is supposed to work cause it’s documented and the official way – opposed to myXML.user.toString()…;-)
Comments on this entry are closed.
{ 1 trackback }