Name
XML.nodeValue Property — the value of the current node
Availability
Flash 5
Synopsis
theNode.nodeValue
Access
Read/write
Description
The nodeValue property reflects the string value
of theNode. Since only two node types
(element nodes and text
nodes) are supported by ActionScript, nodeValue
has only two possible values:
If
theNodeis an element node,nodeValueisnull.
If
theNodeis a text node,nodeValueis the text contained by the node.
In practice, nodeValue is normally used only with
text nodes. 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";Although we may explicitly retrieve the value of a text node using
nodeValue, the toString( )
method implicitly returns a node’s value when it is used in a
string context. Therefore, this code displays the text node’s
text in the Output window:
trace(myDoc.firstChild.firstChild);
See Also
XML
.nodeName,
XML
.nodeType
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access