E4X ‘Gotcha’ With XML in Actionscript 3
Oftentimes, I like to trace pieces of data as I’m programming just to make sure everything is on track. When you’re trying to trace data using E4X (XML in Actionscript 3), don’t forget the toXMLString() function. In many cases, you won’t see anything if you forget to call this function. Your code will see the data just fine, but you might not think it’s working and spend time trying to diagnose a non-existent problem.
trace(xml.children()[0]) //empty trace trace(xml.children()[0].toXMLString()) //now we see it!




hi,
i just wanted to say thank you, that was the “cause” of a non existent problem I’ve been trying to solve for the last 30 minutes!!!
I’m so glad that pages like this exist!
Thanks again!
Comment by joel — June 11, 2009 @ 9:26 pm
Glad to hear it, Joel! That was my hope when posting this.
Comment by Justin — June 11, 2009 @ 9:30 pm