Latest web development tutorials

XML DOM prefix attribute

Element Object Reference Element object

Definition and Usage

prefix property returns the namespace prefix of the selected element.

If the selected node is not an element or attribute, the property always returns NULL.

grammar

elementNode.prefix

Examples

The following code fragment uses loadXMLDoc () to " books_ns.xml " into xmlDoc and obtain namespace prefix from the first <title> element:

Examples

xmlDoc=loadXMLDoc("books_ns.xml");
x=xmlDoc.getElementsByTagName("title")[0];

document.write(x.prefix);

The code above will output:

c

try it"

Element Object Reference Element object