XML DOM baseURI property

Definition and usage

The baseURI property returns the location of the XML document.

Syntax:

elementNode.baseURI

instance

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

The following code snippet shows the location of the XML document:

xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName("book")[0];
document.write("Document location: " + x.baseURI);

The output of the above code is:

Document location: http://www.codew3c.com/dom/books.xml