Table of Contents

XML.nodeName Property Flash 5

the name of the current node read/write
theNode.nodeName

Description

The nodeName string property reflects the name of theNode, where 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:

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


Table of Contents