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

XML DOM nodeName プロパティ


Attr Object Reference Attr オブジェクト

定義と用法

nodeName プロパティは、そのタイプに応じたノード名を返します。

構文

attrObject.nodeName


次のコードは、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)

試してください »

Try-It-Yourself デモ

属性のノード名、ノード値およびノードタイプを表示します


Attr Object Reference Attr オブジェクト