ホーム HTML CSS XML JAVASCRIPT   PHP SQL MORE...   リファレンス 事例集    

XML DOM nodeType プロパティ


Attr Object Reference Attr オブジェクト

定義と用法

nodeType プロパティは、ノードのタイプを返します。

構文

attrObject.nodeType


次のコードは、loadXMLDoc() を使用して xmlDoc に "books.xml" をロードし、 category 属性のノード名、ノード値およびノードタイプを表示します:

xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].nodeName);
document.write(" = ");
document.write(x.item(i).attributes[0].nodeValue);
document.write(" (nodetype: ");
document.write(x.item(i).attributes[0].nodeType + ")");
document.write("<br />");
}

出力:

category = COOKING (nodetype: 2)
category = CHILDREN (nodetype: 2)
category = WEB (nodetype: 2)
category = WEB (nodetype: 2)

試してください »

Attr Object Reference Attr オブジェクト