TUTORIAL前端与浏览器FETCHED
XML DOM nodeType 属性
XML DOM nodeType 属性 Element 对象 定义和用法 nodeType 属性返回选定节点的节点类型。 语法 elementNode.nodeType 节点数量: 节点名称: 1 Element 2 Attribute 3 Text 4 CDATA Section 5 Entity Reference 6 Entity 7 Pro..
更新于 2026/7/16
教程详情页默认 noindex。
XML DOM nodeType 属性
Element 对象
定义和用法
nodeType 属性返回选定节点的节点类型。
语法
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 |
实例
下面的代码片段使用 loadXMLDoc() 把 "books.xml" 载入 xmlDoc 中,并从第一个 <title> 元素取得节点类型:
实例
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("title")[0];
document.write(x.nodeType);
x=xmlDoc.getElementsByTagName("title")[0];
document.write(x.nodeType);
上面的代码将输出:
1
尝试一下 »
尝试一下
Element 对象