Question
XML parsing in flash
Hi,
I'm using the following technique inorder to parse the XML like
this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;....
Just want to known if there is any way in Macromedia flash where in we can you element by names for parsing XML like asdk supported api : element.getElement("name"); instead of indexing.
<?xml version="1.0"?>
<inventors>
<person>
<name>Thomas Edison</name>
<comment>Inventor of cool stuff.</comment>
</person>
<person>
<name>Doug Engelbart</name>
<comment>Invented the Mouse</comment>
</person>
</inventors>
function loadXML(loaded) {
if (loaded) {
_root.inventor = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.comments = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
name_txt.text = _root.inventor;
comment_txt.text = _root.comments;
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("inventors.xml"); element.getElement(OneCardXMLConstants.CARD_LEVEL_NFC_MESSAGE);
Thanks
I'm using the following technique inorder to parse the XML like
this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;....
Just want to known if there is any way in Macromedia flash where in we can you element by names for parsing XML like asdk supported api : element.getElement("name"); instead of indexing.
<?xml version="1.0"?>
<inventors>
<person>
<name>Thomas Edison</name>
<comment>Inventor of cool stuff.</comment>
</person>
<person>
<name>Doug Engelbart</name>
<comment>Invented the Mouse</comment>
</person>
</inventors>
function loadXML(loaded) {
if (loaded) {
_root.inventor = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.comments = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
name_txt.text = _root.inventor;
comment_txt.text = _root.comments;
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("inventors.xml"); element.getElement(OneCardXMLConstants.CARD_LEVEL_NFC_MESSAGE);
Thanks