
XML.nodeType Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
936
|
ActionScript Language Reference
Example
We can use nodeName to check whether the current node has the element name we’re
seeking. For example, here we extract all the content of
H1 tags on the first level of an XML
document (this example also checks for tags named
h1 with a lowercase h):
myDoc = new XML('<H1>first heading</H1><P>content</P>' +
'<H1>second heading</H1><P>content</P>');
for (i = 0; i < myDoc.childNodes.length; i++) {
if (myDoc.childNodes[i].nodeName.toUpperCase() = = "H1") {
trace(myDoc.childNodes[i].firstChild.nodeValue);
}
}
See Also
XML.nodeType, XML.nodeValue
XML.nodeType Property
the type of the current node
Flash 5
read-only
theNode.nodeType
Description
The nodeType is an integer property that returns theNode’s type (theNode can be an XML or
XMLnode instance). Since only two node types are supported by ActionScript—element
nodes and text nodes—
nodeName has only two possible values: 1, if the node is an element
node; and 3, if the node is a text node. These values may seem arbitrary, but actually they
are the appropriate values as stipulated by the DOM. For reference, the other node types in
the DOM are listed in Table R-26.
Table R-26. DOM node types
Node description Node type code
ELEMENT_NODE
*
*
Supported by Flash.
1
ATTRIBUTE_NODE 2
TEXT_NODE
*
3
CDATA_SECTION_NODE ...