E4X ‘Gotcha’ With XML in Actionscript 3

Justin | ActionScript,tips | Wednesday, April 1st, 2009

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!
Share and Enjoy:
  • Digg
  • del.icio.us
  • Fark
  • StumbleUpon
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • Technorati
  • MySpace
  • email
  • Twitter

Related Topics



2 Comments »

  1. 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

  2. Glad to hear it, Joel! That was my hope when posting this.

    Comment by Justin — June 11, 2009 @ 9:30 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

You may use the following html tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped=""> .

Subscribe without commenting

Powered by WordPress