Specifications

448
dom.convertToXHTML()
Availability
Dreamweaver MX
Description
Parses the HTML into a DOM tree, inserts missing items that are required for XHTML, cleans
up the tree, and then writes the tree as clean XHTML. The missing directives, declarations,
elements and attributes that
convertToXHTML() adds to the DOM tree, as necessary, include the
following items:
An XML directive
A doctype declaration
The xmlns attribute in the html element
A head section
A title element
A body section
During the conversion,
dom.convertToXHTML() converts pure HTML tags and attributes to
lowercase, writes HTML tags and attributes with correct XHTML syntax, and adds missing
HTML attributes where it can. This function treats third-party tags and attributes according to
the settings in the Preferences dialog box.
If the document is a template,
dom.convertToXHTML() alerts the user but does not perform the
conversion.
Arguments
None.
Returns
An array of six integers that quantify the following items:
XHTML errors that Dreamweaver fixed
map elements that do not have an id attribute and cannot be fixed
script elements that do not have a type attribute and cannot be fixed
style elements that do not have a type attribute and cannot be fixed
img elements that do not have an alt attribute and cannot be fixed
area elements that do not have an alt attribute and cannot be fixed
Example
In normal use, an extension first calls dreamweaver.openDocument() or
dreamweaver.getDocumentDOM() to get a reference to the document. The extension then calls
dom.getIsXHTMLDocument() to determine whether the document is already in XHTML form.
If it is not, the extension calls
dom.convertToXHTML() to convert the document into XHTML.
Then the extension calls
dreamweaver.saveDocument() to save the converted file with a
new filename.