Chapter 3 DynaScript Predefined Objects


DOMDocument properties

The DOMDocument object inherits all the properties of the DOMNode object, as well as the properties discussed in this section.

doctype property

Syntax

DOMDocument.doctype

Description

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.

Example

To return the DTD associated with the parsed XML document domDoc.

dtd = domDoc.doctype

See also

"DOMDocumentType object".

documentElement property

Syntax

DOMDocument.documentElement

Description

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.

Example

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 );

implementation property

Syntax

DOMDocument.implementation

Description

The DOMImplementation object that handles this document. The implementation features can then be retrieved using the hasFeature method of the DOMImplementation object.

Example

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

See also

"DOMImplementation object".

 


Copyright © 1999 Sybase, Inc. All rights reserved.