XML DOM text attribute

Definition and Usage

The text attribute returns the text of the attribute.

Syntax:

attrObject.text

Tips and Comments

Note:This property is exclusive to Internet Explorer.

Example

In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().

The following code snippet displays the text of the category attribute in the XML document:

xmlDoc=loadXMLDoc("/example/xdom/books.xml");
x=xmlDoc.getElementsByTagName('book');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].text);
document.write("<br />");
}

The output of the above code is:

children
cooking
web
web