XML DOM prefix property
Definition and usage
The prefix property can set or return the namespace prefix of the node.
Syntax:
nodeObject.prefix
Example
In all examples, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
The following code snippet can return the namespace prefix of the <title> element:
xmlDoc=loadXMLDoc("books_ns.xml");
var x=xmlDoc.getElementsByTagName('title');
for(i=0;i<x.length;i++)
{
document.write(x.item(i).prefix
);
document.write("<br />");
}
Output:
c x