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()「」を 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 オブジェクト その他の拡張