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

XML DOM textContent プロパティ


Attr Object Reference Attr オブジェクト

定義と用法

textContent プロパティは、属性のテキスト内容を設定するか返します。

構文

attrObject.textContent


次のコードは、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].textContent);
document.write("<br />");
}

出力:

COOKING
CHILDREN
WEB
WEB

試してください »

Try-It-Yourself デモ

textContent - Set the textual content of an attribute


Attr Object Reference Attr オブジェクト