XMLObject Update
[updated] I'm psyched for the native XML Object in AS3, but I think this AS2 class still has some life to it until we all migrate. Its evolved quite a bit and was my first Open Source Flash contribution.
What's nice about it:
It parses XML childNodes and looks for Twins, ie, identitical nodes. If it's a twin, its an Array. Otherwise it's an Object. I also commented it out really nicely so its easy to read.
It works really well with XRay for visualizing Objects: http://www.osflash.org/xray
here's the class
Spit an RSS feed into it, I used: http://www.odeo.com/profile/Geekinger/rss
Here's the output
Here's how I use it:
public function loadXML(URL):Void{
var scopeUp = this;
var XMLObj = new XML();
XMLObj.ignoreWhite = true;
XMLObj.onLoad = function() {
scopeUp.convertXML(this);
};
XMLObj.load(URL);
}
private function convertXML(xmlObj):Void{
var obj = {};
obj = XMLObject.getObject(xmlObj,false);
//scope down object one level, not necessary, but easier
//change "rss" to whatever your top XML node name is
obj = obj["rss"];
//helpful for extracting Object
findMyProps(obj);
}
private function findMyProps(obj:Object){
//using XRAY works best here to visualize the object structure
_global.tt(obj);
//basic trace
trace("rss.channel.item[0].title: "+obj.channel.item[0].title);
}
Enjoy,
Seth
us
gwoo's posts (22)
seth's posts (21)
Nate's posts (0)
subscribe

archives
June 2007 (1)
May 2007 (2)
March 2007 (1)
November 2006 (1)
October 2006 (2)
August 2006 (3)
July 2006 (1)
June 2006 (2)
May 2006 (1)
April 2006 (5)
March 2006 (11)
February 2006 (4)
January 2006 (4)








