Such an object has standard DOM methods and properties (such as documentElement, etc.). While W3 does specify createDocument(), string parsing and url loading are not standardized abilities, and so there are other methods here to do those operations.
In this library, we refer to the type of such builtin objects as "DomDocument", even though the W3 specifications use just "Document". We find that overly confusing, because despite what may be intended, a browser Document (the type of window.document
) is neither a superset nor subset of a XML DOM object in capabilities.
Note that this currently is not instantiable. It has some static methods that return a DomDocument, and other functions that take a DomDocument as a first argument.
In addition to the methods here for creating a DomDocument, one may also be created via XMLHTTP, in those browsers that support it. Because of its finer control over errors, it may be preferable over createFromUrl.
Static Public Member Functions | |
DomDocument | createEmpty () |
Create an empty DomDocument object. | |
DomDocument | createFromUrl (String url, Function handler) |
A convenience which combines createEmpty and loadUrl. | |
DomDocument | createFromString (String str) |
Return a Dom Document initialized from the provided string of serialized XML. | |
void | loadUrl (DomDocument xmldoc, String url, Function handler) |
Initialize the provided DomDocument object from the contents at the specified url. | |
String | getParseError (DomDocument domdoc) |
Retrieve any parse error of a xml document. | |
String | toXmlString (DomDocument domdoc) |
Serializes the DomDocument into a single String. | |
Static Public Attributes | |
Array | XMLDOM_PROGID = ['Msxml2.DOMDocument.4.0' 'Msxml2.DOMDocument' 'Microsoft.XMLDom'] |
ProgID values to try for Internet Explorer XMLDOM. |
|
Create an empty DomDocument object. The W3 specifies createDocument: http://www.w3.org/TR/DOM-Level-2-Core/core.html If the environment supports the W3 createDocument, that is used for creation. Otherwise, on IE, an ActiveX DomDocument is created: http://msdn.microsoft.com/library/en-us/xmlsdk30/htm/xmobjpmexmldomdocument.asp |
|
Return a Dom Document initialized from the provided string of serialized XML. On IE, this is implemented by Document.loadXML(String): http://msdn.microsoft.com/library/en-us/xmlsdk30/htm/xmmthloadxml.asp On Mozilla, DOMParser is used: http://unstable.elemental.com/mozilla/build/latest/mozilla/extensions/dox/interfacensIDOMParser.html The caller should expect the possibility of a thrown exception, and should also check the value of burst.xml.XmlDoc.getParseError(domdoc).
|
|
A convenience which combines createEmpty and loadUrl. It returns the DomDocument object (though not much can be done with it until the handler is called). |
|
Retrieve any parse error of a xml document. When creating a xml document and it is initialized from a xml string or url, the caller needs to expect either a synchronous exception to be thrown (such as argument or security errors), or an error to be recorded in the xml document itself (such as parse errors). In IE, it has a member variable parseError. In Mozilla, the document structure itself is altered to have a single child with tagName 'parseerror':
|
|
Initialize the provided DomDocument object from the contents at the specified url. There is currently no W3 specification for DomDocument.load(), only for createDocument. (Note that http://www.w3.org/TR/DOM-Level-3-LS is a draft spec for "XML Load and Save".) For DomDocument.load(), Mozilla attempts to follow Microsoft:
For both Mozilla and IE, by default load() is async. Mozilla only supports async, and we do not expose the ability to ask for synchronous loading.
When the load is complete, the provided handler is called with two arguments: Mozilla has no support for progress notification. IE has an API (via readystatechange), but in IE6 it is not helpful (it doesn't always call the handler very frequently, and when it does, the object is not in a queriable state). So we do not expose the ability to register a progress handler.
The error handling behavior in these environments is not totally understood. For now, the caller should expect the possibility of a synchronous throw exception, as well as the need to check for a non-null value from There is no useful return value from this function. This url to be loaded is subject to the usual "same origin" policy with respect to the current document. For a background on these objects, see:
|
|
Serializes the DomDocument into a single String. If available (IE), uses the 'xml' member. Note that in IE, when it loads an XML document into a window and there is no XSL sheet, it uses a default one and the document that you find by serializing is HTML made from that default XSL. In IE6 for example this default html includes various "contentEditable" elements. So for IE we also check for domdoc.XMLDocument.xml Otherwise attempts to use XMLSerializer (in Mozilla, see http://www.mozilla.org/xmlextras/ ). Otherwise it uses burst.xml.DomUtil.serialize |
|
ProgID values to try for Internet Explorer XMLDOM.
About ProgID's for Microsoft XML componentsFirst, note that ProgID values are case-insensitive. Here is a summary of Microsoft MSXML releases:
Here is a summary of ProgID values for XML DOM:
(As a point of trivia, MSXML release 4.0 also renamed the SDK as "Microsoft XML Core Services" from "Microsoft XML Parser".) For the XSLT morass, see http://www.perfectxml.com/articles/xml/XSLTInMSXML.asp |