Name

XML.docTypeDecl Property — the document’s DOCTYPE tag

Availability

Flash 5

Synopsis

XMLdoc.docTypeDecl

Access

Read/write

Description

The docTypeDecl string property specifies the DOCTYPE tag of XMLdoc, if any exists. Otherwise, docTypeDecl is undefined . XMLdoc must be the top-level node in an XML object hierarchy (i.e., an instance of the XML class, not the XMLnode class).

An XML document’s DOCTYPE specifies the name and location of the DTD used to validate the document. ActionScript does not perform validation of XML documents; it merely parses them. We use the DOCTYPE tag to build XML documents that may be validated externally or to identify the type of a loaded XML document.

Example

var myXML = new XML('<?xml version="1.0"?><!DOCTYPE foo SYSTEM "bar.dtd">'
                    + '<P>a short document</P>');

trace(myXML.docTypeDecl);  // Displays: "<!DOCTYPE foo SYSTEM "bar.dtd">"

// Set a new DOCTYPE
myXML.docTypeDecl = '<!DOCTYPE baz SYSTEM "bam.dtd">';

See Also

XML .xmlDecl

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.