Home | Top | Free Ajax Editor | JavaScript Editor | Get Advanced JavaScript and Ajax Editor, Validator and Debugger! 1st JavaScript Editor. |
DOM creation
The DOM standard specifies that a method called createDocument() be available as part of the document.
implementation object. Mozilla follows this specification exactly, enabling you to create an XML
DOM like this:
var oXmlDom = document.implementation.createDocument(“”,””, null);
The three arguments for createDocument() are the namespace URL for the document, the tag name for
the document element, and a document type object (always null, because no support exists for the document
type object in Mozilla).
The previous line of code creates an empty XML DOM. To create an XML
DOM with a document element, just specify the tag name as the second argument:
var oXmlDom = document.implementation.createDocument(“”,”root”, null);
This line of code creates an XML DOM that represents the XML code <root/>. If you specify a namespace
URL in the first argument, you can further define the document element:
var oXmlDom = document.implementation.createDocument(“http://www.wrox.com”, “root”, null);
This line of code creates an XML DOM representing <a0:root xmlns:a0=”http://www.wrox.com”/>.
Mozilla automatically creates a namespace named a0 to represent the URL you entered for the
namespace.
Home | Top | Free Ajax Editor | JavaScript Editor | Get Advanced JavaScript and Ajax Editor, Validator and Debugger! 1st JavaScript Editor. |