03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

nodeValue (XMLNode.nodeValue property)<br />

public nodeValue : String<br />

The node value of the XML object. If the XML object is a text node, the nodeType is 3, <strong>and</strong><br />

the nodeValue is the text of the node. If the XML object is an XML element (nodeType is 1),<br />

nodeValue is null <strong>and</strong> read-only<br />

Example<br />

The following example creates an element node <strong>and</strong> a text node, <strong>and</strong> checks the node value of<br />

each:<br />

// create an XML document<br />

var doc:XML = new XML();<br />

// create an XML node using createElement()<br />

var myNode:XMLNode = doc.createElement("rootNode");<br />

// place the new node into the XML tree<br />

doc.appendChild(myNode);<br />

// create an XML text node using createTextNode()<br />

var myTextNode:XMLNode = doc.createTextNode("textNode");<br />

// place the new node into the XML tree<br />

myNode.appendChild(myTextNode);<br />

trace(myNode.nodeValue);<br />

trace(myTextNode.nodeValue);<br />

// output:<br />

// null<br />

// myTextNode<br />

The following example creates <strong>and</strong> parses an XML packet. The code loops through each child<br />

node, <strong>and</strong> displays the node value using the firstChild property <strong>and</strong><br />

firstChild.nodeValue. When you use firstChild to display contents of the node, it<br />

maintains the &amp; entity. However, when you explicitly use nodeValue, it converts to the<br />

ampers<strong>and</strong> character (&).<br />

var my_xml:XML = new XML("mortongood&evil");<br />

trace("using firstChild:");<br />

for (var i = 0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!