Xml.createtextnode() - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

XML.createTextNode()

Availability
Flash Player 5.
Usage
my_xml.createTextNode(text:String) : XMLNode
Parameters
A string; the text used to create the new text node.
text
Returns
An XMLNode.
Description
Method; creates a new XML text node with the specified text. The new node initially has no
parent, and text nodes cannot have children or siblings. This method returns a reference to the
XML object that represents the new text node. This method and the
method are the constructor methods for creating nodes for an XML object.
Example
The following example creates two XML text nodes using the
places them into existing XML nodes:
// create an XML document
var doc:XML = new XML();
// create three XML nodes using createElement()
var element1:XMLNode = doc.createElement("element1");
var element2:XMLNode = doc.createElement("element2");
var element3:XMLNode = doc.createElement("element3");
// place the new nodes into the XML tree
doc.appendChild(element1);
element1.appendChild(element2);
element1.appendChild(element3);
// create two XML text nodes using createTextNode()
var textNode1:XMLNode = doc.createTextNode("textNode1");
var textNode2:XMLNode = doc.createTextNode("textNode2");
// place the new nodes into the XML tree
element2.appendChild(textNode1);
element3.appendChild(textNode2);
trace(doc);
// output (with line breaks added between tags):
// <element1>
//
<element2>textNode1</element2>
//
<element3>textNode2</element3>
// </element1>
XML.createElement()
method, and
createTextNode()
XML.createTextNode() 1021

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash mx

Table of Contents