Chapter 3 DynaScript Predefined Objects
The DOMDocument
object inherits
all the properties of the DOMNode
object, as well
as the properties discussed in this section.
DOMDocument.doctype
The DOMDocumentType
object
representing the document type declaration (DTD) associated with
this document. XML documents without a DTD return null. DOM Level
1 does not support editing the DTD.
To return the DTD associated with the parsed XML document domDoc.
dtd = domDoc.doctype
DOMDocument.documentElement
Each XML document has a single element that
contains all other elements in the document. This is called the root
element or the document element.
The documentElement
method
returns the DOMElement
object
representing the root element of the XML document.
To parse a document held in xmlString, create a variable holding the root element of the document, and write out the name of that element, enter:
domDoc = toDOMDocument( xmlString );
docElement = domDoc.documentElement;
document.writeln( docElement.tagName );
DOMDocument.implementation
The DOMImplementation
object
that handles this document. The implementation features can then
be retrieved using the hasFeature
method of
the DOMImplementation
object.
This example writes out details of the current implementation.
imp = domDoc.implementation;
document.writeln( "HTML? " + imp.hasFeature( "HTML", "1.0" ) ) ;
document.writeln( "XML? " + imp.hasFeature( "XML", "1.0" ) ) ;
The output from this example is:
HTML? false
XML? true
Copyright © 1999 Sybase, Inc. All rights reserved. |