O'Reilly logo

ActionScript: The Definitive Guide by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 theNode is an element node, nodeValue is null.

  • If theNode is a text node, nodeValue is 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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required