XML DOM prefix property
Definition and usage
The prefix property sets or returns the namespace prefix of the attribute.
Syntax:
attrObject.prefix
instance
In all examples, we will use the XML file books_ns.xml, and the JavaScript function loadXMLDoc().
The following code snippet returns the namespace prefix of the "lang" attribute:
xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName('title');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).attributes[0].prefix
;
document.write("<br />");
}
The output of the above code is:
c x