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

XML DOM value プロパティ


Attr Object Reference Attr オブジェクト

定義と用法

value プロパティは、属性の値を返します。

構文

attrObject.value


次のコードは、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].name);
document.write(" = ");
document.write(x.item(i).attributes[0].value);
document.write("<br />");
}

出力:

category = COOKING
category = CHILDREN
category = WEB
category = WEB

試してください »

Attr Object Reference Attr オブジェクト