XML.createTextNode( ) Method

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
XML.createTextNode( ) Method Flash 5

create a new text node
xmlDoc.createTextNode(text)

Arguments

text

A string containing the text that is to become the nodeValue of the new node.

Returns

A new text node object, with no parent and no children.

Description

The createTextNode( ) method is our primary means of generating new text nodes for inclusion in an XML document object hierarchy. The specified xmlDoc must be the top-level node in an XML object hierarchy (i.e., an instance of the XML class, not the XMLnode class). Note that createTextNode( ) does not insert the element it returns into xmlDoc we must do that ourselves using appendChild( ) or insertBefore( ). For example, here we create and insert a new P element into a document, and then we give that P element a text-node child:

myDoc = new XML(); newP = myDoc.createElement("P"); myDoc.appendChild(newP);     newText = myDoc.createTextNode("This is the first paragraph"); myDoc.firstChild.appendChild(newText);     trace(myDoc);  // Displays: "<P>This is the first paragraph</P>"

Normally, text nodes are stored as the children of element nodes, which are created using createElement( ).

The createTextNode( ) method converts the characters <, >, &, ', and " according to the rules of entity conversion discussed under XML.parseXML( ).

See Also

XML.appendChild( ), XML.cloneNode( ), XML.createElement( ), XML.insertBefore( ), XML.parseXML( )



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net