XML DOM nodeNameプロパティ


Attr 对象参考手册Attr オブジェクト

定義と使用方法

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

構文

attrObject.nodeName


例

以下のコードスニペットはloadXMLDoc()「」を xmlDoc に読み込み、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: " + 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)

試してみる »

試してみる Demos


Attr 对象参考手册Attr オブジェクト その他の拡張