polyGeek.com
polyGeek.com

PXP2

Polygeek Xml Parsing Project (PXP2)

If you’re building a RIA (Rich Internet Application) you’ll probably be dealing with XML by either loading an XML file from the server or using a web service. Externalizing your data is the only way to fly. The downside is dealing with the XML data inside of Flash. There’s all that childNode, nextSibling, parentNode crap to deal with to get at your data.

Download PXP2 class and examples zip file. (2007.03.09 Note: I have changed my namespace from “polyGeekcom” to “com.polygeek” – yes, I know I should have done that in the first place.)

What would be nice is to parse your XML data into an Object. Suppose you have the following XML:

<blogroll>
     <blog>polyGeek.com</blog>
</blogroll>

Wouldn’t it be nice to get to that string of data with this sort of code:

trace(blogRoll.blog) // ouptut: polyGeek.com

Or if we have this XML:

<blogroll>
     <blog>polyGeek.com</blog>
     <blog>flashden.net/article</blog>
     <blog>weblogs.macromedia.com/jd</blog>
     <blog>blog.digitalbackcountry.com</blog>
     <blog>blogs.zdnet.com/Stewart</blog>
     <blog>richardleggett.co.uk/blog</blog>
     <blog>www.gskinner.com/blog</blog>
</blogroll>

We would like to be able to do this:

var len:Number = blogRoll.blog.length;
for(var i:Number = 0; i &lt; len; ++i) {
     trace(blogRoll.blog[i]);
}

And get the following output:

polyGeek.com
flashden.net/article
weblogs.macromedia.com/jd
blog.digitalbackcountry.com
blogs.zdnet.com/Stewart
richardleggett.co.uk/blog
www.gskinner.com/blog

Next: Make it so

Share and Enjoy:
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Technorati
  • Digg
  • Facebook
  • Slashdot

2 Responses to “PXP2”



[...] a bit I discovered that each attribute was actually typed as XML. I’m a bit spoiled by my PXP2 class which automatically types values as Number, Boolean or [...]


[...] an XML-to-Object converter. The PXP2 class is included in the zip file. You don’t need to read the complete overview of PXP2 to do this [...]

   




© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
Ajax CommentLuv Enabled 816cf46662e57ab1b89821d8e1e32a6b
M2 Websites
Local Directory for Los Angeles, CA