public nodeType : Number [read-only]
A nodeType value, either 1 for an XML element or 3 for a text node.
The nodeType is a numeric value from the NodeType enumeration in the W3C DOM Level 1 recommendation: www.w3.org/tr/1998/REC-DOM-Level-1-19981001/level-one-core.html. The following table lists the values:
|
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 built-in XML class only supports 1 (ELEMENT_NODE) and 3 (TEXT_NODE).
The following example creates an element node and a text node, and checks the node type of each:
// create an XML document
var doc:XML = new XML();
// create an XML node using createElement()
var myNode:XMLNode = doc.createElement("rootNode");
// place the new node into the XML tree
doc.appendChild(myNode);
// create an XML text node using createTextNode()
var myTextNode:XMLNode = doc.createTextNode("textNode");
// place the new node into the XML tree
myNode.appendChild(myTextNode);
trace(myNode.nodeType);
trace(myTextNode.nodeType);
// output:
// 1
// 3