0

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 
1
  • how to accept the answer. I did click the up arrow. Is there somewhere else? lol don't where to accept. I see now. The check mark Commented Dec 21, 2010 at 19:40

1 Answer 1

1

You are trying to use methods or properties on your XML that are not existent: Neither status, nor firstChild, nor nodeName are 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 in

<root>
   <status />
    <firstChild />
</root>

and 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:

var MaintainXML : XML = <letter><to>senocular</to><body>Get a life</body></letter>;

trace( "nodeName:" + MaintainXML.to.name() ); // traces "to"
trace( "nodeValue:" + MaintainXML.to.toString() ); // traces "senocular"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.