| Adds the specified node to the Document as the documentElement. |
Signature: setDocumentElement(&$node) |
Parameters:
DOMIT_Node node - 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 setDocumentElement: $mydoc->setDocumentElement($elementNode); |
| Specifies whether DOMIT! will try to fix invalid XML before parsing begins. |
Signature: resolveErrors($truthVal) |
Parameters:
boolean truthVal - True if errors are to be resolved.
|
Example:
Error resolution is turned on: $mydoc->resolveErrors(true); |
| Specifies whether DOMIT! processes namespace information. |
Signature: setNamespaceAwareness($truthVal) |
Parameters:
boolean truthVal - True if namespaces are to be processed.
|
Example:
Namespaces are to be processed: $mydoc->setNamespaceAwareness(true);
$myDoc->loadXML('my.xml', true); |
| Specifies the parametersof the http conection used to obtain the xml data. |
Signature: setConnection($host, $path = '/', $port = 80, $timeout = 0, $user = null, $password = null) |
Parameters:
String host - The ip address or domain name of the connection.
String path - The path of the connection.
int port - The port that the connection is listening on.
int timeout - The timeout value for the connection.
String user - The user name, if authentication is required.
String password - The password, if authentication is required.
|
Example:
A manual HTTP connection is specified: $xmldoc->setConnection('http://www.engageinteractive.com'); |
| Specifies basic authentication for an http connection. |
Signature: setAuthorization($user, $password) |
Parameters:
String user - The user name.
String password - The password.
|
Example:
Authorization is specified for the HTTP connection: $xmldoc->setAuthorization('johndoe', 'xyzzy'); |
| Specifies the parameters of the http conection used to obtain the xml data. |
Signature: setProxyConnection($host, $path = '/', $port = 80, $timeout = 0, $user = null, $password = null) |
Parameters:
String host - The ip address or domain name of the connection.
String path - The path of the connection.
int port - The port that the connection is listening on.
int timeout - The timeout value for the connection.
String user - The user name, if authentication is required.
String password - The password, if authentication is required.
|
Example:
A HTTP proxy connection is specified: $xmldoc->setProxyConnection('http://www.engageinteractive.com'); |
| Specifies basic authentication for an http connection. |
Signature: setProxyAuthorization($user, $password) |
Parameters:
String user - The user name.
String password - The password.
|
Example:
Authorization is specified for the HTTP connection: $xmldoc->setProxyAuthorization('johndoe', 'xyzzy'); |
| Returns the error code from the underlying SAX parser. |
Signature: getErrorCode() |
Returns:
int - The error code.
|
Example:
The error code is returned: echo $mydoc->getErrorCode(); |
| Returns the error string from the underlying SAX parser. |
Signature: getErrorString() |
Returns:
String - The error string.
|
Example:
The error string is returned: echo $mydoc->getErrorString(); |
| Specifies whether elements tags will be rendered to string as <element></element> rather than <element/>. |
Signature: expandEmptyElementTags($truthVal, $expandEmptyElementExceptions = false) |
Parameters:
boolean truthVal - True if empty element tags are to be expanded.
array expandEmptyElementExceptions - An array of tag name exceptions to the expansion rule.
|
Example:
Entity tag expansion is turned on, except for br and img tags: $mydoc->expandEmptyElementTags(true, array('br','img')); |
| Adds the specified node as either the documentElement, a processing instruction, or a comment. |
Signature: &appendChild(&$child) |
Parameters:
DOMIT_Node child - The node that is to be appended. Only a single node can serve as documentElement, so an existing documentElement node will be overwritten.
|
Returns:
DOMIT_Node - The appended node.
|
Example:
The documentElement of a tree is assigned using appendChild: $mydoc->appendChild($elementNode); |
| Replaces node $oldChild (the documentElement) with $newChild. |
Signature: replaceChild(&$newChild, &$oldChild) |
Parameters:
DOMIT_Node newChild - The new node that is to replace the old node.
DOMIT_Node oldChild - The old node that is to be replaced by the new node.
|
Returns:
DOMIT_Node - The new node $newChild, or false if $oldChild does not exist.
|
Example:
The documentElement node is replaced by a new node: $myDoc->replaceChild($newDocElem, $oldDocElem); |
| Removes the specified node (the documentElement) from the document. |
Signature: &removeChild(&$oldChild) |
Parameters:
DOMIT_Node oldChild - The node that is to be removed.
|
Returns:
DOMIT_Node - The deleted node $oldChild, or false if $oldChild does not exist.
|
Example:
The documentElement node is removed from the document. $mydoc->removeNode($docElem); |
| Creates a new instance of a DOMIT_DocumentFragment, "lightweight" Document object that can be used to temporarily store nodes (not present in DOMIT_Lite). |
Signature: &createDocumentFragment() |
Returns:
DOMIT_DocumentFragment - The newly created DOMIT_DocumentFragment.
|
Example:
A new DOMIT_DocumentFragment can be created in the following manner: $myDocFrag =& $xmldoc->createDocumentFragment(); |
| Creates a new instance of a DOMIT_Attr (not present in DOMIT_Lite, attributes are an associative array instead). |
Signature: &createAttribute($name) |
Parameters:
String name - The key of the DOMIT_Attr to be created.
|
Returns:
DOMIT_Attr - The newly created DOMIT_Attr.
|
Example:
A new DOMIT_Attr can be created in the following manner: $myAttr =& $xmldoc->createAttribute("id"); |
| Creates a new instance of a DOMIT_Attr, namespace aware (not present in DOMIT_Lite, attributes are an associative array instead). |
Signature: &createAttributeNS($namespaceURI, $qualifiedName) |
Parameters:
String namespaceURI - The namespaceURI of the attribute.
String qualifiedName - The qualifiedName of the attribute.
|
Returns:
DOMIT_Attr - The newly created DOMIT_Attr.
|
Example:
A new DOMIT_Attr can be created in the following manner: $myAttr =& $xmldoc->createAttributeNS("http://www.engageinteractive.com", "ei:description"); |
| Creates a new instance of a DOMIT_Element. |
Signature: &createElement($tagName) |
Parameters:
String tagName - 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"); |
| Creates a new instance of a DOMIT_Element, namespace aware. |
Signature: &createElementNS($namespaceURI, $qualifiedName) |
Parameters:
String namespaceURI - The namespaceURI of the element.
String qualifiedName - The qualifiedName of the element.
|
Returns:
DOMIT_Element - The newly created DOMIT_Element.
|
Example:
A new DOMIT_Element can be created in the following manner: $myBook =& $xmldoc->createElementNS("http://purl.org/dc/elements/1.1", "dc:creator"); |
| Creates a new instance of a DOMIT_TextNode. |
Signature: &createTextNode($data) |
Parameters:
String data - 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."); |
| Creates a new instance of a DOMIT_CDATASection. |
Signature: &createCDATASection($data) |
Parameters:
String data - 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("&*^%$#@"); |
| Creates a new instance of a DOMIT_Comment (not present in DOMIT_Lite). |
Signature: &createComment($text) |
Parameters:
String text - The text of the DOMIT_Comment to be created.
|
Returns:
DOMIT_Comment - The newly created DOMIT_Comment.
|
Example:
A new DOMIT_Comment can be created in the following manner: $comment =& new DOMIT_Comment("This is a comment"); |
| Creates a new instance of a DOMIT_ProcessingInstruction (not present in DOMIT_Lite). |
Signature: &createProcessingInstruction($target, $data) |
Parameters:
String target - The target of the DOMIT_ProcessingInstruction to be created.
String data - The data of the DOMIT_ProcessingInstruction to be created.
|
Returns:
DOMIT_ProcessingInstruction - The newly created DOMIT_ProcessingInstruction.
|
Example:
A new DOMIT_ProcessingInstruction can be created in the following manner: $pi =& $xmldoc->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"iso-8859-1\""); |
| Generates an DOMIT_NodeList 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, or "*" if all elements are to be returned.
|
Returns:
DOMIT_NodeList - The DOMIT_NodeList of found DOMIT_Elements.
|
Example:
Here, all elements named "poem" that fall under the $poems node are returned as a DOMIT_NodeList: $poems =& $library->getElementsByTagName("poem"); |
| Retrieves a NodeList of child elements with the specified namespaceURI and localName. |
Signature: &getElementsByTagNameNS($namespaceURI, $localName) |
Parameters:
String namespaceURI - The matching namespaceURI, or "*" if all elements are to be returned.
String localName - The matching localName, or "*" if all elements are to be returned.
|
Returns:
DOMIT_NodeList - The DOMIT_NodeList of found DOMIT_Elements.
|
Example:
A DOMIT_NodeList of matching elements is returned: $authors =& $library->getElementsByTagNameNS("http://purl.org/dc/elements/1.1", "creator"); |
| Retrieves an element or DOMIT_NodeList of elements corresponding to an Xpath-like expression. |
Signature: &getElementsByPath($pattern, $nodeIndex = 0) |
Parameters:
String pattern - The query pattern.
int nodeIndex - If a single node is to be returned (rather than the entire NodeList) the index of that node.
|
Returns:
DOMIT_NodeList - A NodeList or single node that matches the pattern.
|
| Returns the element whose ID is given by elementId. |
Signature: &getElementByID($elementID, $isStrict = true) |
Parameters:
String elementID - The id of the matching element.
boolean isStrict - True if XML spec is to be strictly adhered to (only attributes xml:id are considered valid).
|
Returns:
DOMIT_Element - An element matching the query.
|
Example:
A matching DOMIT_Element is returned: $element =& $xmldoc->getElementByID("0231", true); |
| 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 = true, $preserveCDATA = true, $fireLoadEvent = 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.
boolean preserveCDATA - True (or omitted) to retain CDATASection nodes, false to convert into Text Nodes
boolean fireLoadEvent - false (or omitted) if the onLoad() function is NOT to be called for each node after the DOMIT_Document is created, true if the event is to be triggered.
|
Example:
The xml string will be parsed using the SAXY parser: $xmldoc->parseXML("<book><title>Using DOMIT!</title><author>John Heinstein</author></book>", true); |
| THIS METHOD IS NO LONGER RECOMMENDED!!! Parses the xml string provided into a hierarchy of DOMIT_Nodes under the current DOMIT_Document. The string is first encoded as UTF-8, so that non ASCII characters can be interpreted properly. Either the Expat extension or the included SAXY_Parser class can be specified to perform the parsing. Note that if the UTF-8 encoded data is to be displayed in a browser, you should set the header of your web page to UTF-8 encoding using the printUTF8Header() method. |
Signature: parseXML_utf8($xmlText, $useSAXY = true, $preserveCDATA = true, $fireLoadEvent = false) |
Parameters:
String xmlText - The xml text to be parsed.It will be encoded as UTF-8, so that non US-ASCII characters can be interpreted properly.
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.
boolean preserveCDATA - True (or omitted) to retain CDATASection nodes, false to convert into Text Nodes
boolean fireLoadEvent - false (or omitted) if the onLoad() function is NOT to be called for each node after the DOMIT_Document is created, true if the event is to be triggered.
|
Example:
The xml string, utf-8 encoded, will be parsed using the SAXY parser: $xmldoc->parseXML_utf8("<book><title>Using DOMIT!</title><author>John Heinstein</author></book>", true); |
| Parses the xml string located at the specified url or local file. Either the Expat extension or the included SAXY_Parser class can be specified to perform the parsing. |
Signature: loadXML($fileName, $useSAXY = true, $preserveCDATA = true, $fireLoadEvent = false) |
Parameters:
String fileName - The file name (url or local file) containing the xml 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.
boolean preserveCDATA - True (or omitted) to retain CDATASection nodes, false to convert into Text Nodes
boolean fireLoadEvent - false (or omitted) if the onLoad() function is NOT to be called for each node after the DOMIT_Document is created, true if the event is to be triggered.
|
Returns:
boolean - True if the xml parsed properly.
|
Example:
The xml string in file myFile.xml will be parsed using the SAXY parser: $xmldoc->loadXML("http://www.someurl.com/myFile.xml", true); |
| THIS METHOD IS NO LONGER RECOMMENDED!!! Parses the xml string located at the specified url or local file. The string is first encoded as UTF-8, so that non ASCII characters can be interpreted properly. Either the Expat extension or the included SAXY_Parser class can be specified to perform the parsing. Note that if the UTF-8 encoded data is to be displayed in a browser, you should set the header of your web page to UTF-8 encoding using the DOMIT_Utilities::printUTF8Header() method. |
Signature: loadXML_utf8($fileName, $useSAXY = true, $preserveCDATA = true, $fireLoadEvent = false) |
Parameters:
String fileName - The file name (url or local file) containing the xml 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.
boolean preserveCDATA - True (or omitted) to retain CDATASection nodes, false to convert into Text Nodes
boolean fireLoadEvent - false (or omitted) if the onLoad() function is NOT to be called for each node after the DOMIT_Document is created, true if the event is to be triggered.
|
Returns:
boolean - True if the xml parsed properly.
|
Example:
The xml string in file myFile.xml will be utf8 encoded and parsed using the SAXY parser: $xmldoc->loadXML_utf8("http://www.someurl.com/myFile.xml", true); |
| Gets the text located at the specified url or local file. |
Signature: getTextFromFile($filename) |
Parameters:
String fileName - The file name (url or local file) containing the text to be retrieved.
|
Returns:
String - The text contained in the specified file.
|
Example:
The string in file myFile.txt will be retrieved: $myText = $xmldoc->getTextFromFile("http://www.someurl.com/myFile.txt"); |
| Saves the current DOM document as XML text at the specified location. |
Signature: saveXML($fileName, $normalized=false) |
Parameters:
String fileName - The file name (url or local file) to which the XML is to be saved.
String normalized - If set to true, a whitespace formatted representation of the xml will be saved. Default is false.
|
Returns:
boolean - True if the file is saved properly.
|
Example:
The current document will be saved as myFile.xml: $success = $xmldoc->saveXML("http://www.someurl.com/myFile.xml"); |
| THIS METHOD IS NO LONGER RECOMMENDED!!! Saves the current DOM document as XML text at the specified location. |
Signature: saveXML_utf8($fileName, $normalized=false) |
Parameters:
String fileName - The file name (url or local file) to which the XML is to be saved. The string is first encoded as UTF-8, so that non ASCII characters can be interpreted properly.
|
Returns:
boolean - True if the file is saved properly.
|
Example:
The current document, utf8 encoded, will be saved as myFile.xml: $success = $xmldoc->saveXML_utf8("http://www.someurl.com/myFile.xml"); |
| Saves the specified text located to the specified url or local file. |
Signature: saveTextToFile($fileName, $text) |
Parameters:
String fileName - The file name (url or local file) where the specified text is to be written.
String text - The text to be written to the specified file name.
|
Returns:
boolean - True if the save is successful.
|
Example:
The specified string will be saved as myFile.txt: $success = $xmldoc->saveTextToFile("../myFile.txt", "This is a test"); |
| Returns the name of the parser used to create the document, either "SAXY" or "EXPAT". |
Signature: parsedBy() |
Returns:
String - The name of the parser used to create the document, either "SAXY" or "EXPAT". An empty string is returned if the document is empty.
|
Example:
The name of the parser is returned: $myParser = $xmldoc->parsedBy(); |
| Returns a copy of the specified node, and if $deep is set to true, all nodes below it in the hierarchy. |
Signature: &cloneNode($deep) |
Parameters:
boolean deep - True if the children below the cloned node are also to be cloned.
|
Returns:
DOMIT_Node - The cloned node, with a clone of all subnodes if $deep is set to true.
|
Example:
In the following example, a node named $styleTemplate is cloned, presumably so the user can create a new style based on the characteristics of the original node. $newStyle =& styleTemplate->cloneNode(false); |
| Allows you to search the document tree for nodes of a specific type, returning the found nodes in a DOMIT_NodeList (not present in DOMIT_Lite). |
Signature: &getNodesByNodeType($type, &$contextNode) |
Parameters:
int type - A DOMIT! constant referring to the node type, one of: DOMIT_DOCUMENT_NODE (9), DOMIT_ELEMENT_NODE (1), DOMIT_TEXT_NODE (3), DOMIT_CDATA_SECTION_NODE (4).
DOMIT_Node contextNode - An element or document node from which the search should begin.
|
Returns:
DOMIT_NodeList - A DOMIT_NodeList containing the found nodes.
|
Example:
All elements in the document will be returned. $allElements =& $xmldoc->getNodesByNodeType(DOMIT_ELEMENT_NODE, $xmldoc); |
| Allows you to search the document tree for nodes of a specific value, returning the found nodes in a DOMIT_NodeList (not present in DOMIT_Lite). |
Signature: &getNodesByNodeValue($value, &$contextNode) |
Parameters:
String value - The text to search for in any text/cdata nodes that are encountered.
DOMIT_Node contextNode - An element or document node from which the search should begin.
|
Returns:
array - A DOMIT_NodeList containing the found nodes.
|
Example:
All text nodes in the document containing the string "Richard Thompson" will be returned. $textNodes =& $cdCollectionDoc->getNodesByNodeValue("Richard Thompson", $cdCollectionDoc); |
| Returns the text contained in all DOMIT_TextNodes and DOMIT_CDataSections that are children of the specified starting node |
Signature: getText() |
Returns:
String - The text contained in the children of the specified node.
|
Example:
All text and cdata nodes in the document will be concatenated and returned. $allDocmentText = $xmldoc->getText(); |
| Returns the text of the xml declaration if one exists for the current document. |
Signature: getXMLDeclaration() |
Returns:
String - The text of the xml declaration if one exists for the current document.
|
Example:
The xml declaration will be returned. $xmldec = $xmldoc->getXMLDeclaration(); |
| Returns the text of the doctype if one exists for the current document. NOTE: this is a non-standard implementation - the DOM spec will be implemented eventually, however. |
Signature: getDocType() |
Returns:
String - The text of the doctype if one exists for the current document.
|
Example:
The doctype will be returned. $doctype= $xmldoc->getDocType(); |
| Returns a reference to the DOMIT_DOMImplementation instance. |
Signature: &getDOMImplementation() |
Returns:
DOMIT_DOMImplementation - The DOMIT_DOMImplementation reference.
|
Example:
A reference to the DOMIT_DOMImplementation will be returned and used to determine compliance with the DOM HTML spec. $domRef =& $xmldoc->getDOMImplementation();
$supportsHTML = $domRef->hasFeature("HTML") |
| Returns the current version of DOMIT! |
Signature: getVersion() |
Returns:
String - The current version of DOMIT!
|
Example:
Returns the current version of DOMIT! $currentVersion = $xmldoc->getVersion(); |
| Appends an array of entity mappings to the existing translation table. Intended mainly to facilitate the conversion of non-ASCII entities into equivalent characters |
Signature: appendEntityTranslationTable($table) |
Parameters:
Array table - A list of entity mappings in the format: array('&' => '&');
|
| Returns an array representation of the xml document. |
Signature: toArray() |
Returns:
array - An array representing the xml document.
|
Example:
Prints out an array representing the xml document. print_r($xmldoc->toArray()); |
| Generates an unformatted (single line, no whitespace) string representation of the document and all children. |
Signature: toString($htmlSafe = false, $subEntities=false) |
Parameters:
boolean htmlSafe - If true, returns an html formatted representation of the string.
boolean subEntities - True if illegal xml characters in text nodes and attributes should be converted to entities.
|
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 $myDoc->toString(true); |