I am trying to parse out the nodeName but nothing was return, what is wrong with my script?
import flash.xml.XMLDocument;
import flash.xml.XMLNode;
import flash.xml.XMLNodeType;
var MaintainXML:XML =
<letter><to>senocular</to><body>Get a life</body></letter>;
trace("status"+MaintainXML.status); // traces "0" (No error)
trace("nodeName" + MaintainXML.firstChild.nodeName); // traces "letter"
trace("nodeName" + MaintainXML.firstChild.firstChild.nodeName); // traces "to"
trace("nodeValue"+MaintainXML.firstChild.firstChild.firstChild.nodeValue); // traces
You are trying to use methods or properties on your XML that are not existent: Neither
status, norfirstChild, nornodeNameare available for the XML Object. Flash will interpret those calls as a search query, so it looks for child nodes with the name “status”, resp. “firstChild” as inand returns an empty XMLList, because of course it cannot find such nodes.
Also, your MaintainXMLs root node is
<letter>, so the first child would be<to>.Try this: