Latest web development tutorials

XML DOM nodeType property

Element Object Reference Element object

Definition and Usage

nodeType property returns the node type selected node.

grammar

elementNode.nodeType

节点数量: 节点名称:
1 Element
2 Attribute
3 Text
4 CDATA Section
5 Entity Reference
6 Entity
7 Processing Instruction
8 Comment
9 Document
10 Document Type
11 Document Fragment
12 Notation


Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc and get the node type from the first <title> element:

Examples

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName("title")[0];
document.write(x.nodeType);

The code above will output:

1

try it"

Try Demos

nodeType - ignores empty text nodes


Element Object Reference Element object