Reading XML from Flash
- June 19th, 2010
- Posted in Flash
- Write comment
Here is the way
supposing we have XML that have this structure
<?xml version=”1.0″ encoding=”UTF-8″?>
<products>
<item Title= ” Home ” Desciption=”" />
</products>
///set up this default, not worth explaining
XML.prototype.ignoreWhite = true;
///Create a new empty XML Object
var myXML:XML = new XML();///load in the xml file
myXML.load(“products.xml”);
//if the XML file has successfully loaded in, then this function is run through
myXML.onLoad = function(success) {
if (success) {
i=0;
//new array for the total number of childNodes
menuArray = new Array();
menuArray = this.firstChild.childNodes;
while (i<menuArray.length) {
trace(this.firstChild.childNodes[i].attributes.Title);
i++;
}
}
};
No comments yet.