Class DOMIT_Document
A class representing the DOM Document.

isPublic? yes
isAbstract? no

Inheritance tree:

DOMIT_Node
|
DOMIT_Document

Known subclasses:

None

Source file: xml_domit_parser.php




Constructor
Initializes DOMIT_Document variables and those of the superclass.

Signature: DOMIT_Document()

isPublic? no




Public Constants



Private Constants



Public Fields
xmlDeclaration
A string representing the xml declaration of the document. Note that this value must be manually assigned; neither the SAXY nor the Expat parsers process xml declarations.

Type: String

doctype
A string representing the document type of the document. Note that this value must be manually assigned; neither the SAXY nor the Expat parsers process document types.

Type: String

documentElement
A reference to the root element of the DOMIT_Document. Null if unassigned.

Type: DOMIT_Element




Private Fields



Public Methods
appendChild
Adds the specified node as the documentElement.

Signature: appendChild(&$child)

Parameters:

DOMIT_Node child - The node that is to be appended as documentElement. Only a single node can serve as documentElement, so an existing documentElement node will be overwritten.

Returns:

DOMIT_Node - The appended documentElement node.

Example:

The documentElement of a tree is assigned using appendChild:

$mydoc->appendChild($elementNode);

createElement
Creates a new instance of a DOMIT_Element.

Signature: createElement($name)

Parameters:

String name - The tagName of the DOMIT_Element to be created.

Returns:

DOMIT_Element - The newly created DOMIT_Element.

Example:

A new DOMIT_Element can be created in the following manner:

$myBook = $xmldoc->createElement("book");

createTextNode
Creates a new instance of a DOMIT_TextNode.

Signature: createTextNode($text)

Parameters:

String text - The text of the DOMIT_TextNode to be created.

Returns:

DOMIT_TextNode - The newly created DOMIT_TextNode.

Example:

A new DOMIT_TextNode can be created in the following manner:

$myBookCritique = $xmldoc->createTextNode("A really good read.");

createCDATASection
Creates a new instance of a DOMIT_CDATASection.

Signature: createCDATASection($text)

Parameters:

String text - The text of the DOMIT_CDATASection to be created.

Returns:

DOMIT_CDATASection - The newly created DOMIT_CDATASection.

Example:

A new DOMIT_CDataSection can be created in the following manner:

$curseWord = $xmldoc->createCDATASection("&*^%$#@");

getElementsByTagName
Generates an array of DOMIT_Elements with the specified $tagName that are present in the document.

Signature: &getElementsByTagName($tagName)

Parameters:

String tagName - The tag name of the DOMIT_Elements to be searched for.

Returns:

array - The array of found DOMIT_Elements.

Example:

Here, all elements named "poem" that fall under the $poems node are returned in an array:

$poems =& $library->getElementsByTagName("poem");

parseXML
Parses the xml string provided into a hierarchy of DOMIT_Nodes under the current DOMIT_Document. Either the Expat extension or the included SAXY_Parser class can be specified to perform the parsing.

Signature: parseXML($xmlText, $useSAXY = false)

Parameters:

String xmlText - The xml text to be parsed.

boolean useSAXY - false (or omitted) if the Expat parser is to be used, true if SAXY is used. Note that since SAXY is not a C extension as is Expat, there is no question as to its availability. It is also slightly faster than Expat, although possibly not as robust.

Example:

The xml string will be parsed using the SAXY parser:

$xmldoc->parseXML("<book><title>Using DOMIT!</title><author>John Heinstein</author></book>", true);

toString
Generates an unformatted (single line, no whitespace) string representation of the document and all children.

Signature: toString()

Returns:

String - An unformatted (single line, no whitespace) string representation of the document and all children.

Example:

An unformatted string representation of the xml document will be printed here:

echo (htmlentities($myDoc->toString());




Private Methods
createClone
Used by cloneNode() to generate a new instance of a DOMIT_Document containing the same data as the original.

Signature: &createClone()

Returns:

DOMIT_Document - A new DOMIT_Document


Documentation generated by ClassyDoc, using the DOMIT! and SAXY parsers.
Please visit Engage Interactive to download free copies.