XML.nodeValue Property | Flash 5 |
the value of a node, as a string | read/write |
The nodeValue property reflects the string value of theNode, where theNode can be an XML or XMLnode instance. Since only two node types (element nodes and text nodes) are supported by ActionScript, nodeValue has only two possible values:
If theNode is an element node, nodeValue is null.
If theNode is a text node, nodeValue is the text contained by the node.
To assign new text to an existing text node, we use nodeValue as follows:
// Create a new XML document myDoc = new XML('<H1>first heading</H1><P>content</P>'); // Change the text contained by the H1 tag myDoc.firstChild.firstChild.nodeValue = "My Life Story";
To retrieve the text of a text node, we simply read its nodeValue property:
trace(myDoc.firstChild.firstChild.nodeValue);
Note that, in nodeValue, the predefined entities <, >, &, ", and ' are represented as the literal characters <, >, &, ", and '. To obtain the source code for a node, including uninterpreted entities, use XML.toString( ). For more details, see XML.parseXML( ).
When a node is used in a string context, Flash uses XML.toString( ), not nodeValue, to represent its value:
// Force an implicit datatype conversion. Calls toString( ). trace(myDoc.firstChild.firstChild); // Same as: trace(myDoc.firstChild.firstChild.toString());
XML.nodeName, >, XML.parseXML( ), XML.toString( )