ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > XMLNode > XMLNode constructor | |||
The XMLNode constructor lets you instantiate an XML node based on a string specifying its contents and on a number representing its node type.
Availability: ActionScript 1.0; Flash Player 8
type:Number - An integer representing the node type:
|
Integer value |
Defined constant |
|---|---|
|
1 |
ELEMENT_NODE |
|
2 |
ATTRIBUTE_NODE |
|
3 |
TEXT_NODE |
|
4 |
CDATA_SECTION_NODE |
|
5 |
NTITY_REFERENCE_NODE |
|
6 |
ENTITY_NODE |
|
7 |
PROCESSING_INSTRUCTION_NODE |
|
8 |
COMMENT_NODE |
|
9 |
DOCUMENT_NODE |
|
10 |
DOCUMENT_TYPE_NODE |
|
11 |
DOCUMENT_FRAGMENT_NODE |
|
12 |
NOTATION_NODE |
In Flash Player, the XML class only supports node types 1 (ELEMENT_NODE) and 3 (TEXT_NODE).
value:String - For a text node, this is the text of the node; for an element node, this is the contents of the tag.
var ELEMENT_NODE:Number = 1;
var node1:XMLNode = new XMLNode(ELEMENT_NODE, "fullName");
var TEXT_NODE:Number = 3;
var node2:XMLNode = new XMLNode(TEXT_NODE, "Justin Case");
// Create a new XML document
var doc:XML = new XML();
// Create a root node
var rootNode:XMLNode = doc.createElement("root");
// Add the rootNode as the root of the XML document tree
doc.appendChild(rootNode);
// Build the rest of the document:
rootNode.appendChild(node1);
node1.appendChild(node2);
trace(doc);
// Output: Justin Case
|
|
|
|