PDA

View Full Version : xml nodes


crayons
08-27-2007, 03:12 PM
Hi Everyone, as this is my first post.
I am quite inexperienced but eager to learn actionScript, i'm a bit of an adapt-a-script cowboy really but hope to break out of that!

Can anybody helpme with the xml handler? I am trying to parse a .rss xml file using one of the tutorial scripts (i'll be honest about it), the xml that works with this script is structured somewhat differently to the standard rss
the script may look familiar, it propogates a menu from an xml list.

menuXml = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function(success) {
if (success) {

//i think this section scopes down to the required level in the xml
menuItem = this.firstChild.childNodes;
for (var i = 0; i<menuItem.length; i++) {
item = _root.attachMovie("itemClip", "itemClip"+i, i);
item._x = 0;
item._y = 20*i;
item.itemLabel.text = menuItem[i].attributes.name;
item.myUrl = menuItem[i].attributes.url;
item.onRelease = function() {
getURL(this.myUrl, "_blank");
};
}
}
};
menuXml.load("myMenu.xml");


this works fine with the tutorial's supplied xml script but when i try it out with the rss i get a menu but it says undefined in all the entries.

any thoughts?

- nick (crayons)

Alexus
08-27-2007, 04:33 PM
hm... the best way is to try to read at least one node correctlly. Try to trace nodeName and attributes and catch the problem.
You also can see this project (http://flashmenulabs.com/opensource/FML_Open_Source_Edition.zip)
See class CMenuVertClassicXMLReader.as it parses XML file and contains several useful functions like FindChildWithName
Good luck