XML DOM localName property

Definition and usage

The localName property returns the local part of the attribute name.

Syntax:

attrObject.localName

Instance

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

The following code snippet returns the local name of the "lang" attribute:

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

The output of the above code is:

lang
lang
lang
lang

TIY

Get the localName of the attribute(Not supported by IE browser)