XML.createElement( ) Method

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

create a new element node
xmlDoc.createElement(tagName)

Arguments

tagName

A case-sensitive string indicating the name of the element to create. For example, in the tag, <P ALIGN="RIGHT">, P is the tag name.

Returns

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

Description

The createElement( ) method is our primary means of generating new element 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 createElement( ) 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:

myDoc = new XML(); newP = myDoc.createElement("P"); myDoc.appendChild(newP);

We can combine those steps by using this:

myDoc.appendChild(myDoc.createElement("P"));

The createElement( ) method cannot be used to create text nodes; use createTextNode( ) instead.

See Also

XML.appendChild( ), XML.cloneNode( ), XML.createTextNode( ), XML.insertBefore( )



    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