XML DOM isId Attribute

Definition and Usage

If the attribute is of ID type (for example, it contains the identifier of its parent element), the isId attribute returns true, otherwise it returns false.

Syntax:

attrObject.isId

Example

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

The following code snippet returns whether the category attribute is the ID attribute of the <book> element:

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

The output of the above code should be:

false
false
false
false

TIY

isId - Get whether the attribute is of ID type(Not supported by IE browser)