steinm Thu Apr 11 11:46:58 2002 EDT Modified files: /phpdoc/en/functions domxml.xml Log: - huge update of documentation - started to describe the object oriented interface of this extension
Index: phpdoc/en/functions/domxml.xml diff -u phpdoc/en/functions/domxml.xml:1.37 phpdoc/en/functions/domxml.xml:1.38 --- phpdoc/en/functions/domxml.xml:1.37 Fri Mar 15 16:22:11 2002 +++ phpdoc/en/functions/domxml.xml Thu Apr 11 11:46:57 2002 @@ -1,421 +1,691 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.37 $ --> +<!-- $Revision: 1.38 $ --> <reference id="ref.domxml"> <title>DOM XML functions</title> <titleabbrev>DOM XML</titleabbrev> <partintro> + + <sect1 id="domxml-intro"> + <title>Introduction</title> &warn.experimental; - <simpara> - This documentation is not finished yet. Don't start to translate it - or use it as a programming reference ([EMAIL PROTECTED]). - </simpara> - <simpara> + <para> + This documentation is not finished yet. Don't start to translate it + or use it as a programming reference ([EMAIL PROTECTED]). + </para> + <para> + The extension allows you to operate on an XML document with the DOM API. + It also provides a function <function>xmltree</function> to turn the + complete XML document into a tree of PHP objects. Currently this + tree should be considered read-only - you can modify it but this + would not make any sense since <function>dumpmem</function> cannot be + applied to it. Therefore, if you want to read an XML file and write + a modified version use the <function>DomDocument_create_element</function>, + <function>DomDocument_create_text</function>, + <function>set_attribute</function>, etc. and finally + <function>dumpmem</function> functions. + </para> + </sect1> + + <sect1 id="domxml-requirements"> + <title>Requirements</title> + <para> These functions are only available if PHP was configured with <option role="configure">--with-dom=[DIR]</option>, using the <ulink url="&url.domxml;">GNOME xml library</ulink>. You will need at least libxml-2.2.7 These functions have been added in PHP 4. - </simpara> - <simpara> - The extension allows you to operate on an XML document with the DOM API. - It also provides a function <function>xmltree</function> to turn the - complete XML document into a tree of PHP objects. Currently this - tree should be considered read-only - you can modify it but this - would not make any sense since <function>dumpmem</function> cannot be - applied to it. Therefore, if you want to read an XML file and write - a modified version use the <function>add_node</function>, - <function>set_attribute</function>, etc. and finally - <function>dumpmem</function> functions. - </simpara> - <simpara> - This module defines the following constants: - </simpara> - <table> - <title>XML constants</title> - <tgroup cols="3"> - <thead> - <row> - <entry>Constant</entry> - <entry>Value</entry> - <entry>Description</entry> - </row> - </thead> - <tbody> - <row> - <entry>XML_ELEMENT_NODE</entry> - <entry>1</entry> - <entry>Node is an element</entry> - </row> - <row> - <entry>XML_ATTRIBUTE_NODE</entry> - <entry>2</entry> - <entry>Node is an attribute</entry> - </row> - <row> - <entry>XML_TEXT_NODE</entry> - <entry>3</entry> - <entry>Node is a piece of text</entry> - </row> - <row> - <entry>XML_CDATA_SECTION_NODE</entry> - <entry>4</entry> - <entry></entry> - </row> - <row> - <entry>XML_ENTITY_REF_NODE</entry> - <entry>5</entry> - <entry></entry> - </row> - <row> - <entry>XML_ENTITY_NODE</entry> - <entry>6</entry> - <entry>Node is an entity like &nbsp;</entry> - </row> - <row> - <entry>XML_PI_NODE</entry> - <entry>7</entry> - <entry>Node is a processing instruction</entry> - </row> - <row> - <entry>XML_COMMENT_NODE</entry> - <entry>8</entry> - <entry>Node is a comment</entry> - </row> - <row> - <entry>XML_DOCUMENT_NODE</entry> - <entry>9</entry> - <entry>Node is a document</entry> - </row> - <row> - <entry>XML_DOCUMENT_TYPE_NODE</entry> - <entry>10</entry> - <entry></entry> - </row> - <row> - <entry>XML_DOCUMENT_FRAG_NODE</entry> - <entry>11</entry> - <entry></entry> - </row> - <row> - <entry>XML_NOTATION_NODE</entry> - <entry>12</entry> - <entry></entry> - </row> - <row> - <entry>XML_GLOBAL_NAMESPACE</entry> - <entry>1</entry> - <entry></entry> - </row> - <row> - <entry>XML_LOCAL_NAMESPACE</entry> - <entry>2</entry> - <entry></entry> - </row> - </tbody> - </tgroup> - </table> - <simpara> - Each function in this extension can be used in two ways. In a non-object - oriented way by passing the object to apply the function to as a first - argument, or in an object oriented way by calling the function as a method - of an object. This documentation describes the non-object oriented - functions, though you get the object methods by skipping the prefix - "domxml_". - </simpara> - <simpara> - This module defines a number of classes, which are listed — - including their - properties and method — in the following table. - </simpara> - <para> - <table> - <title>DomDocument class (methods)</title> - <tgroup cols="3"> - <thead> - <row> - <entry>Method name</entry> - <entry>Function name</entry> - <entry>Description</entry> - </row> - </thead> - <tbody> - <row> - <entry>root</entry> - <entry><function>domxml_root</function></entry> - <entry></entry> - </row> - <row> - <entry>children</entry> - <entry><function>domxml_children</function></entry> - <entry></entry> - </row> - <row> - <entry>add_root</entry> - <entry><function>domxml_add_root</function></entry> - <entry></entry> - </row> - <row> - <entry>dtd</entry> - <entry><function>domxml_intdtd</function></entry> - <entry></entry> - </row> - <row> - <entry>dumpmem</entry> - <entry><function>domxml</function></entry> - <entry></entry> - </row> - <row> - <entry>xpath_init</entry> - <entry>xpath_init</entry> - <entry></entry> - </row> - <row> - <entry>xpath_new_context</entry> - <entry>xpath_new_context</entry> - <entry></entry> - </row> - <row> - <entry>xptr_new_context</entry> - <entry>xptr_new_context</entry> - <entry></entry> - </row> - </tbody> - </tgroup> - </table> - </para> - - <para> - <table> - <title>DomDocument class (attributes)</title> - <tgroup cols="3"> - <thead> - <row> - <entry>Name</entry> - <entry>Type</entry> - <entry>Description</entry> - </row> - </thead> - <tbody> - <row> - <entry>doc</entry> - <entry>class DomDocument</entry> - <entry>The object itself</entry> - </row> - <row> - <entry>name</entry> - <entry>string</entry> - <entry></entry> - </row> - <row> - <entry>url</entry> - <entry>string</entry> - <entry></entry> - </row> - <row> - <entry>version</entry> - <entry>string</entry> - <entry>Version of XML</entry> - </row> - <row> - <entry>encoding</entry> - <entry>string</entry> - <entry></entry> - </row> - <row> - <entry>standalone</entry> - <entry>long</entry> - <entry>1 if the file is a standalone version</entry> - </row> - <row> - <entry>type</entry> - <entry>long</entry> - <entry>One of the constants in table ... </entry> - </row> - <row> - <entry>compression</entry> - <entry>long</entry> - <entry>1 if the file is compressed</entry> - </row> - <row> - <entry>charset</entry> - <entry>long</entry> - <entry></entry> - </row> - </tbody> - </tgroup> - </table> - </para> - - <para> - <table> - <title>DomNode class (methods)</title> - <tgroup cols="3"> - <thead> - <row> - <entry>Name</entry> - <entry>PHP name</entry> - <entry>Description</entry> - </row> - </thead> - <tbody> - <row> - <entry>lastchild</entry> - <entry><function>domxml_last_child</function></entry> - <entry></entry> - </row> - <row> - <entry>children</entry> - <entry><function>domxml_children</function></entry> - <entry></entry> - </row> - <row> - <entry>parent</entry> - <entry><function>domxml_parent</function></entry> - <entry></entry> - </row> - <row> - <entry>new_child</entry> - <entry><function>domxml_new_child</function></entry> - <entry></entry> - </row> - <row> - <entry>get_attribute</entry> - <entry><function>domxml_get_attribute</function></entry> - <entry></entry> - </row> - <row> - <entry>set_attribute</entry> - <entry><function>domxml_set_attribute</function></entry> - <entry></entry> - </row> - <row> - <entry>attributes</entry> - <entry><function>domxml_attributes</function></entry> - <entry></entry> - </row> - <row> - <entry>node</entry> - <entry><function>domxml_node</function></entry> - <entry></entry> - </row> - <row> - <entry><function>set_content</function></entry> - <entry>domxml_set_content</entry> - <entry></entry> - </row> - </tbody> - </tgroup> - </table> - </para> - - <para> - <table> - <title>DomNode class (attributes)</title> - <tgroup cols="3"> - <thead> - <row> - <entry>Name</entry> - <entry>Type</entry> - <entry>Description</entry> - </row> - </thead> - <tbody> - <row> - <entry>node</entry> - <entry>class DomNode</entry> - <entry>The object itself</entry> - </row> - <row> - <entry>type</entry> - <entry>long</entry> - <entry></entry> - </row> - <row> - <entry>tagname</entry> - <entry>string</entry> - <entry></entry> - </row> - <row> - <entry>content</entry> - <entry>string</entry> - <entry></entry> - </row> - </tbody> - </tgroup> - </table> - </para> + </para> + </sect1> + <sect1 id="domxml-constants"> + <title>Constants</title> + <para> + This module defines the following constants: + </para> + <table> + <title>XML constants</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Constant</entry> + <entry>Value</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>XML_ELEMENT_NODE</entry> + <entry>1</entry> + <entry>Node is an element</entry> + </row> + <row> + <entry>XML_ATTRIBUTE_NODE</entry> + <entry>2</entry> + <entry>Node is an attribute</entry> + </row> + <row> + <entry>XML_TEXT_NODE</entry> + <entry>3</entry> + <entry>Node is a piece of text</entry> + </row> + <row> + <entry>XML_CDATA_SECTION_NODE</entry> + <entry>4</entry> + <entry></entry> + </row> + <row> + <entry>XML_ENTITY_REF_NODE</entry> + <entry>5</entry> + <entry></entry> + </row> + <row> + <entry>XML_ENTITY_NODE</entry> + <entry>6</entry> + <entry>Node is an entity like &nbsp;</entry> + </row> + <row> + <entry>XML_PI_NODE</entry> + <entry>7</entry> + <entry>Node is a processing instruction</entry> + </row> + <row> + <entry>XML_COMMENT_NODE</entry> + <entry>8</entry> + <entry>Node is a comment</entry> + </row> + <row> + <entry>XML_DOCUMENT_NODE</entry> + <entry>9</entry> + <entry>Node is a document</entry> + </row> + <row> + <entry>XML_DOCUMENT_TYPE_NODE</entry> + <entry>10</entry> + <entry></entry> + </row> + <row> + <entry>XML_DOCUMENT_FRAG_NODE</entry> + <entry>11</entry> + <entry></entry> + </row> + <row> + <entry>XML_NOTATION_NODE</entry> + <entry>12</entry> + <entry></entry> + </row> + <row> + <entry>XML_GLOBAL_NAMESPACE</entry> + <entry>1</entry> + <entry></entry> + </row> + <row> + <entry>XML_LOCAL_NAMESPACE</entry> + <entry>2</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </sect1> + + <sect1 id="domxml-classes"> + <title>Classes</title> + <para> + The API of the module follows the DOM Level 2 standard as close + as possible. Consequently the API is fully object oriented. + It is a good idea to have the DOM standard available when + using this module. + Though the API is object oriented there are many functions which can + be called in a non-object oriented way by passing the object to operate + on as the first argument. These function are mainly to retain compatibilty + to older versions of the extension but are not encouraged to use anymore + in new developments. + </para> + <para> + This API differs from the official DOM API in two points. First, all + class attributes are implemented as functions with the same name and + secondly the function names follow the PHP naming convention. This means + that a DOM function lastChild() will be written as last_child(). + </para> + <para> + This module defines a number of classes, which are listed — + including their + method — in the following tables. Classes with an equivalent in the + DOM Standard are named DOMxxx. + </para> + + <para> + <table> + <title>List of classes</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Class name</entry> + <entry>Parent classes</entry> + </row> + </thead> + <tbody> + <row> + <entry>DomAttribute</entry> + <entry>DomNode</entry> + </row> + <row> + <entry>DomCData</entry> + <entry>DomNode</entry> + </row> + <row> + <entry>DomComment</entry> + <entry>DomCData : DomNode</entry> + </row> + <row> + <entry>DomDocument</entry> + <entry>DomNode</entry> + </row> + <row> + <entry>DomDocumentType</entry> + <entry>DomNode</entry> + </row> + <row> + <entry>DomElement</entry> + <entry>DomNode</entry> + </row> + <row> + <entry>DomEntity</entry> + <entry>DomNode</entry> + </row> + <row> + <entry>DomEntityReference</entry> + <entry>DomNode</entry> + </row> + <row> + <entry>DomProcessingInstruction</entry> + <entry>DomNode</entry> + </row> + <row> + <entry>DomText</entry> + <entry>DomCData : DomNode</entry> + </row> + <row> + <entry>DomParser</entry> + <entry></entry> + </row> + <row> + <entry>XPathContext<function>></function></entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + <table> + <title>DomDocument class (DomDocument : DomNode)</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Method name</entry> + <entry>Function name</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>doctype</entry> + <entry><function>DomDocument_doctype</function></entry> + <entry>Returns the document type</entry> + </row> + <row> + <entry>document_elemnent</entry> + <entry><function>DomDocument_document_element</function></entry> + <entry></entry> + </row> + <row> + <entry>create_element</entry> + <entry><function>DomDocument_create_element</function></entry> + <entry></entry> + </row> + <row> + <entry>create_text_node</entry> + <entry><function>DomDocument_create_text_node</function></entry> + <entry></entry> + </row> + <row> + <entry>create_comment</entry> + <entry><function>DomDocument_create_comment</function></entry> + <entry></entry> + </row> + <row> + <entry>create_cdata_section</entry> + <entry><function>DomDocument_create_cdata_section</function></entry> + <entry></entry> + </row> + <row> + <entry>create_processing_instruction</entry> + <entry><function>DomDocument_create_processing_instruction</function></entry> + <entry></entry> + </row> + <row> + <entry>create_attribute</entry> + <entry><function>DomDocument_create_attribute</function></entry> + <entry></entry> + </row> + <row> + <entry>create_entity_reference</entry> + <entry><function>DomDocument_create_entity_reference</function></entry> + <entry></entry> + </row> + <row> + <entry>get_elements_by_tagname</entry> + <entry><function>DomDocument_get_elements_by_tagname</function></entry> + <entry></entry> + </row> + <row> + <entry>get_element_by_id</entry> + <entry><function>DomDocument_get_element_by_id</function></entry> + <entry></entry> + </row> + <row> + <entry>add_root</entry> + <entry><function>domxml_add_root</function></entry> + <entry></entry> + </row> + <row> + <entry>dtd</entry> + <entry><function>domxml_intdtd</function></entry> + <entry></entry> + </row> + <row> + <entry>dumpmem</entry> + <entry><function>domxml</function></entry> + <entry></entry> + </row> + <row> + <entry>xpath_init</entry> + <entry>xpath_init</entry> + <entry></entry> + </row> + <row> + <entry>xpath_new_context</entry> + <entry>xpath_new_context</entry> + <entry></entry> + </row> + <row> + <entry>xptr_new_context</entry> + <entry>xptr_new_context</entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + <table> + <title>DomElement class (DomElement : DomNode)</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Method name</entry> + <entry>Function name</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>tagname</entry> + <entry><function>DomElement_tagname</function></entry> + <entry></entry> + </row> + <row> + <entry>get_attribute</entry> + <entry><function>DomElement_get_attribute</function></entry> + <entry></entry> + </row> + <row> + <entry>set_attribute</entry> + <entry><function>DomElement_set_attribute</function></entry> + <entry></entry> + </row> + <row> + <entry>remove_attribute</entry> + <entry><function>DomElement_remove_attribute</function></entry> + <entry></entry> + </row> + <row> + <entry>get_attribute_node</entry> + <entry><function>DomElement_get_attribute_node</function></entry> + <entry></entry> + </row> + <row> + <entry>set_attribute_node</entry> + <entry><function>DomElement_set_attribute_node</function></entry> + <entry></entry> + </row> + <row> + <entry>get_elements_by_tagname</entry> + <entry><function>DomElement_get_elements_by_tagname</function></entry> + <entry></entry> + </row> + <row> + <entry>has_attribute</entry> + <entry><function>DomElement_has_attribute</function></entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + <table> + <title>DomNode class</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Method name</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry><function>DomNode_node_name</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_node_value</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_node_type</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_last_child</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_first_child</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_child_nodes</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_previous_sibling</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_next_sibling</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_parent_node</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_owner_document</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_insert_before</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_append_child</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_has_child_nodes</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_has_attributes</function></entry> + <entry></entry> + </row> + <row> + <entry>new_child</entry> + <entry>Not in DOM standard</entry> + </row> + <row> + <entry>get_attribute</entry> + <entry>Not in DOM standard</entry> + </row> + <row> + <entry>set_attribute</entry> + <entry>Not in DOM standard</entry> + </row> + <row> + <entry>DomNode_attributes</entry> + <entry></entry> + </row> + <row> + <entry>node</entry> + <entry>Not in DOM standard</entry> + </row> + <row> + <entry><function>set_content</function></entry> + <entry>Not in DOM standard</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + <table> + <title>DomAttribute class (DomAttribute : DomNode)</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Method name</entry> + <entry></entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>name</entry> + <entry><function>DomAttribute_name</function></entry> + <entry></entry> + </row> + <row> + <entry>value</entry> + <entry><function>DomAttribute_value</function></entry> + <entry></entry> + </row> + <row> + <entry>specified</entry> + <entry><function>DomAttribute_specified</function></entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + <table> + <title>DomProcessingInstruction class (DomProcessingInstruction : +DomNode)</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Method name</entry> + <entry>Function name</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>target</entry> + <entry><function>DomProcessingInstruction_target</function></entry> + <entry></entry> + </row> + <row> + <entry>data</entry> + <entry><function>DomProcessingInstruction_data</function></entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + <table> + <title>DomParser class</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Method name</entry> + <entry>Function name</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>add_chunk</entry> + <entry><function>DomParser_add_chunk</function></entry> + <entry></entry> + </row> + <row> + <entry>end</entry> + <entry><function>DomParser_end</function></entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + <table> + <title>XPathContext class</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Method name</entry> + <entry>Function name</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>eval</entry> + <entry><function>XPathContext_eval</function></entry> + <entry></entry> + </row> + <row> + <entry>eval_expression</entry> + <entry><function>XPathContext_eval_expression</function></entry> + <entry></entry> + </row> + <row> + <entry>register_ns</entry> + <entry><function>XPathContext_register_ns</function></entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + <table> + <title>DomDocumentType class (DomDocumentType : DomNode)</title> + <tgroup cols="3"> + <thead> + <row> + <entry>Method name</entry> + <entry>Function name</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>name</entry> + <entry><function>DomDocumentType_name</function></entry> + <entry></entry> + </row> + <row> + <entry>entities</entry> + <entry><function>DomDocumentType_entities</function></entry> + <entry></entry> + </row> + <row> + <entry>notations</entry> + <entry><function>DomDocumentType_notations</function></entry> + <entry></entry> + </row> + <row> + <entry>public_id</entry> + <entry><function>DomDocumentType_public_id</function></entry> + <entry></entry> + </row> + <row> + <entry>system_id</entry> + <entry><function>DomDocumentType_system_id</function></entry> + <entry></entry> + </row> + <row> + <entry>internal_subset</entry> + <entry><function>DomDocumentType_internal_subset</function></entry> + <entry></entry> + </row> + </tbody> + </tgroup> + </table> + </para> + + <para> + The classes DomDtd is derived from DomNode. DomComment is derived from + DomCData + </para> + </sect1> + + <sect1 id="domxml-examples"> + <title>Examples</title> + <para> + Many examples in this reference require a xml string. Instead of + repeating this string in any example it will be put into a file + and be included by each example. This include file is shown in the + following example section. + <example> + <title>Include file example.inc with xml string</title> + <programlisting role="php"> +<![CDATA[ +<?php +$xmlstr = "<?xml version='1.0' standalone='yes'?> +<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd' +[ <!ENTITY sp \"spanish\"> +]> +<!-- lsfj --> +<chapter language='en'><title language='en'>Title</title> + <para language='ge'> + &sp; + <!-- comment --> + <informaltable ID='findme' language='&sp;'> + <tgroup cols='3'> + <tbody> + <row><entry>a1</entry><entry +morerows='1'>b1</entry><entry>c1</entry></row> +<row><entry>a2</entry><entry>c2</entry></row> + <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> + </tbody> + </tgroup> + </informaltable> + </para> +</chapter>"; +?> +]]> + </programlisting> + </example> + </para> + </sect1> </partintro> - <!-- class Dom document --> - <!-- has member functions - array root([int doc_handle]) - returns array of root nodes of this document. Array - elements are objects of class "Dom node" having properties of - "node" (resource), "type" (long), "name" (string) - and optionally "content" (string). - - array children([ int node ]) - returns an array of child nodes of this element. Array - elements are objects of class "Dom node" having properties - of "node" (resource), "type" (long), "name" (string) - and optionally "content" (string). - - object add_root([int doc_handle,] string name) - Add a root node to document. - - returns an object of class "Dom node" having properties - of "node" (resource), "type" (long), "name" (string) - and optionally "content" (string). - - object intdtd([int doc_handle]) - returns the DTD of document. - - returns an object of class "Dtd" having properties - of "dtd" (resource), "sysid" (string), "name" (string) - and optionally "extid" (string). - - string dumpmem([int doc_handle]) - dumps document into string. - --> - - <!-- class Dom node - object lastchild([int node]) - returns Dom node object - - array children([int node]) - as above - - object parent([ int node]) - returns Dom node object - (parent of this node) - - new_child - string getattr([int node,] string attrname) - get value of attribute named attrname - - bool setattr([int node,] string attrname, string value) - set value of given attribute. - - array attributes([int node]) - returns associative array of (string name, string value) - pairs. - - object node(string name) - creates a named Dom node object. - --> - - <!-- class Dom Attribute - name - --> - - <!-- class Dom Namespace - --> - - <!-- class Dtd - --> - <refentry id="function.xmldoc"> <refnamediv> <refname>xmldoc</refname> @@ -467,7 +737,7 @@ <refnamediv> <refname>xmltree</refname> <refpurpose> - Creates a tree of PHP objects from XML document + Creates a tree of PHP objects from an XML document </refpurpose> </refnamediv> <refsect1> @@ -490,62 +760,65 @@ </refsect1> </refentry> - <refentry id="function.domxml-root"> + <!-- Start of class DomDocument --> + + <refentry id="function.DomDocument-doctype"> + <refnamediv> + <refname>DomDocument->doctype</refname> + <refpurpose> + Returns the document type + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomDocument->doctype</methodname> + <void/> + </methodsynopsis> + <para> + This function returns an object of class + <classname>DomDocumentType</classname>. In versions of + PHP before 4.3 this has been the class <classname>Dtd</classname>, + but the DOM Standard does not know such a class. + </para> + <para> + See also the methods of class <classname>DomDocumentType</classname>. + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-document-element"> <refnamediv> - <refname>domxml_root</refname> + <refname>DomDocument->document_element</refname> <refpurpose> Returns root element node </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>domxml_root</methodname> - <methodparam><type>object</type><parameter>doc</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; + <methodsynopsis> + <type>object</type><methodname>DomDocument->document_element</methodname> + <void/> + </methodsynopsis> <para> - <function>domxml_root</function> takes one argument, an object of class - "Dom document", and returns the root element node. There are actually - other possible nodes like comments which are currently disregarded. + This function returns the root element node of a document. </para> <para> The following example returns just the element with name CHAPTER and - prints it. The other root node -- the comment -- is not returned. + prints it. The other node -- the comment -- is not returned. <example> <title>Retrieving root element</title> <programlisting role="php"> <![CDATA[ <?php -$xmlstr = "<?xml version='1.0' standalone='yes'?> -<!DOCTYPE chapter SYSTEM '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd' -[ <!ENTITY sp \"spanish\"> -]> -<!-- lsfj --> -<chapter language='en'><title language='en'>Title</title> - <para language='ge'> - &sp; - <!-- comment --> - <informaltable language='&sp;'> - <tgroup cols='3'> - <tbody> - <row><entry>a1</entry><entry -morerows='1'>b1</entry><entry>c1</entry></row> -<row><entry>a2</entry><entry>c2</entry></row> - <row><entry>a3</entry><entry>b3</entry><entry>c3</entry></row> - </tbody> - </tgroup> - </informaltable> - </para> -</chapter>"; +include("example.inc"); if(!$dom = xmldoc($xmlstr)) { echo "Error while parsing the document\n"; exit; } -$root = $dom->root(); -/* or $root = domxml_root($dom); */ +$root = $dom->document_element(); print_r($root); ?> ]]> @@ -555,6 +828,297 @@ </refsect1> </refentry> + <refentry id="function.DomDocument-create-element"> + <refnamediv> + <refname>DomDocument->create_element</refname> + <refpurpose> + Create new element node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomDocument->create_element</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + </methodsynopsis> + <para> + This function returns a new instance of class + <classname>DomElement</classname>. The tag name of the element is the + value of the passed parameter. This node will not show up in the + document unless it is inserted with e.g. + <function>DomNode_append_child</function>. + </para> + <para> + The return value is false if an error occured. + </para> + <para> + See also <function>DomNode_append_child</function>, + <function>DomDocument_create_text</function>, + <function>DomDocument_create_comment</function>, + <function>DomDocument_create_attribute</function>, + <function>DomDocument_create_processing_instruction</function>, + <function>DomDocument_create_entity_reference</function>, + <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-create-text-node"> + <refnamediv> + <refname>DomDocument->create_text_node</refname> + <refpurpose> + Create new text node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomDocument->create_text_node</methodname> + <methodparam><type>string</type><parameter>content</parameter></methodparam> + </methodsynopsis> + <para> + This function returns a new instance of class + <classname>DomText</classname>. The content of the text is the value of + the passed + parameter. This node will not show up in the + document unless it is inserted with e.g. + <function>DomNode_append_child</function>. + </para> + <para> + The return value is false if an error occured. + </para> + <para> + See also <function>DomNode_append_child</function>, + <function>DomDocument_create_element</function>, + <function>DomDocument_create_comment</function>, + <function>DomDocument_create_text</function>, + <function>DomDocument_create_attribute</function>, + <function>DomDocument_create_processing_instruction</function>, + <function>DomDocument_create_entity_reference</function>, + <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-create-comment"> + <refnamediv> + <refname>DomDocument->create_comment</refname> + <refpurpose> + Create new comment node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomDocument->create_comment</methodname> + <methodparam><type>string</type><parameter>content</parameter></methodparam> + </methodsynopsis> + <para> + This function returns a new instance of class + <classname>DomComment</classname>. The content of the comment is the + value of the passed parameter. This node will not show up in the + document unless it is inserted with e.g. + <function>DomNode_append_child</function>. + </para> + <para> + The return value is false if an error occured. + </para> + <para> + See also <function>DomNode_append_child</function>, + <function>DomDocument_create_element</function>, + <function>DomDocument_create_text</function>, + <function>DomDocument_create_attribute</function>, + <function>DomDocument_create_processing_instruction</function>, + <function>DomDocument_create_entity_reference</function>, + <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-create-cdata-section"> + <refnamediv> + <refname>DomDocument->create_cdata_section</refname> + <refpurpose> + Create new cdata node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomDocument->create_cdata_section</methodname> + <methodparam><type>string</type><parameter>content</parameter></methodparam> + </methodsynopsis> + <para> + This function returns a new instance of class + <classname>DomCData</classname>. The content of the cdata is the + value of the passed parameter. This node will not show up in the + document unless it is inserted with e.g. + <function>DomNode_append_child</function>. + </para> + <para> + The return value is false if an error occured. + </para> + <para> + See also <function>DomNode_append_child</function>, + <function>DomDocument_create_element</function>, + <function>DomDocument_create_text</function>, + <function>DomDocument_create_attribute</function>, + <function>DomDocument_create_processing_instruction</function>, + <function>DomDocument_create_entity_reference</function>, + <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-create-processing-instruction"> + <refnamediv> + <refname>DomDocument->create_processing_instruction</refname> + <refpurpose> + Creates new PI node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + +<type>string</type><methodname>DomDocument->create_processing_instruction</methodname> + <methodparam><type>string</type><parameter>content</parameter></methodparam> + </methodsynopsis> + <para> + This function returns a new instance of class + <classname>DomCData</classname>. The content of the pi is the + value of the passed parameter. This node will not show up in the + document unless it is inserted with e.g. + <function>DomNode_append_child</function>. + </para> + <para> + The return value is false if an error occured. + </para> + <para> + See also <function>DomNode_append_child</function>, + <function>DomDocument_create_element</function>, + <function>DomDocument_create_text</function>, + <function>DomDocument_create_cdata_section</function>, + <function>DomDocument_create_attribute</function>, + <function>DomDocument_create_entity_reference</function>, + <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-create-attribute"> + <refnamediv> + <refname>DomDocument->create_attribute</refname> + <refpurpose> + Create new attribute + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomDocument->create_attribute</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + <methodparam><type>string</type><parameter>value</parameter></methodparam> + </methodsynopsis> + <para> + This function returns a new instance of class + <classname>DomAttribute</classname>. The name of the attribute is the + value of the first parameter. The value of the attribute is the value of + the second parameter. This node will not show up in the + document unless it is inserted with e.g. + <function>DomNode_append_child</function>. + </para> + <para> + The return value is false if an error occured. + </para> + <para> + See also <function>DomNode_append_child</function>, + <function>DomDocument_create_element</function>, + <function>DomDocument_create_text</function>, + <function>DomDocument_create_cdata_section</function>, + <function>DomDocument_create_processing_instruction</function>, + <function>DomDocument_create_entity_reference</function>, + <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-create-entity-reference"> + <refnamediv> + <refname>DomDocument->create_entity_reference</refname> + <refpurpose> + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomDocument->create_entity_reference</methodname> + <methodparam><type>string</type><parameter>content</parameter></methodparam> + </methodsynopsis> + <para> + This function returns a new instance of class + <classname>DomEntityReference</classname>. The content of the entity + reference is the + value of the passed parameter. This node will not show up in the + document unless it is inserted with e.g. + <function>DomNode_append_child</function>. + </para> + <para> + The return value is false if an error occured. + </para> + <para> + See also <function>DomNode_append_child</function>, + <function>DomDocument_create_element</function>, + <function>DomDocument_create_text</function>, + <function>DomDocument_create_cdata_section</function>, + <function>DomDocument_create_processing_instruction</function>, + <function>DomDocument_create_attribute</function>, + <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-get-elements-by-tagname"> + <refnamediv> + <refname>DomDocument->get_elements_by_tagname</refname> + <refpurpose> + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>array</type><methodname>DomDocument->get_elements_by_tagname</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + </methodsynopsis> + <para> + </para> + <para> + See also <function>domxml_add_root</function> + </para> + </refsect1> + </refentry> + + <refentry id="function.DomDocument-get-element-by-id"> + <refnamediv> + <refname>DomDocument->get_element_by_id</refname> + <refpurpose> + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomDocument->get_element_by_id</methodname> + <methodparam><type>string</type><parameter>id</parameter></methodparam> + </methodsynopsis> + <para> + </para> + <para> + See also <function>domxml_add_root</function> + </para> + </refsect1> + </refentry> + + <!-- End of class DomDocument --> + <refentry id="function.domxml-add-root"> <refnamediv> <refname>domxml_add_root</refname> @@ -842,98 +1406,1026 @@ </refsect1> </refentry> - <refentry id='function.domxml-node'> + <!-- Start of class DomElement --> + + <refentry id='function.DomElement-tagname'> <refnamediv> - <refname>domxml_node</refname> + <refname>DomElement->tagname</refname> <refpurpose> - Creates node + Returns name of element </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>domxml_node</methodname> - <methodparam><type>string</type><parameter>name</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>string</type><methodname>DomElement->tagname</methodname> + <void/> + </methodsynopsis> <para> &warn.undocumented.func; </para> </refsect1> </refentry> - <refentry id='function.domxml-node-set-content'> + <refentry id='function.DomElement-get-attribute'> <refnamediv> - <refname>domxml_node_set_content</refname> + <refname>DomElement->get_attribute</refname> <refpurpose> - Sets content of a node + Returns value of attribute </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>bool</type><methodname>domxml_node_set_content</methodname> - <methodparam><type>string</type><parameter>content</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>object</type><methodname>DomElement->get_attribute</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + </methodsynopsis> <para> &warn.undocumented.func; </para> </refsect1> </refentry> - <refentry id='function.domxml-node-unlink-node'> + <refentry id='function.DomElement-set-attribute'> <refnamediv> - <refname>domxml_node_unlink_node</refname> + <refname>DomElement->set_attribute</refname> <refpurpose> - Deletes node + Adds new attribute </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>domxml_node_unlink_node</methodname> - <void/> - </methodsynopsis> + <methodsynopsis> + <type>bool</type><methodname>DomElement->set_attribute</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + <methodparam><type>string</type><parameter>value</parameter></methodparam> + </methodsynopsis> <para> &warn.undocumented.func; </para> </refsect1> </refentry> - <refentry id="function.xpath-eval-expression"> + <refentry id='function.DomElement-get-attribute-node'> <refnamediv> - <refname>xpath_eval_expression</refname> + <refname>DomElement->get_attribute_node</refname> <refpurpose> - Evaluates the XPath Location Path in the given string + Returns value of attribute </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>array</type><methodname>xpath_eval_expression</methodname> - <methodparam><type>object</type><parameter>xpath_context</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; - <para> - </para> + <methodsynopsis> + <type>object</type><methodname>DomElement->get_attribute_node</methodname> + <methodparam><type>object</type><parameter>attr</parameter></methodparam> + </methodsynopsis> <para> - See also <function>xpath_eval</function> + &warn.undocumented.func; </para> </refsect1> </refentry> - <refentry id='function.domxml-version'> + <refentry id='function.DomElement-set-attribute-node'> <refnamediv> - <refname>domxml_version</refname> + <refname>DomElement->set_attribute_node</refname> <refpurpose> - Get XML library version + Adds new attribute </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>string</type><methodname>domxml_version</methodname> - <void/> - </methodsynopsis> + <methodsynopsis> + <type>bool</type><methodname>DomElement->set_attribute_node</methodname> + <methodparam><type>object</type><parameter>attr</parameter></methodparam> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomElement-remove-attribute'> + <refnamediv> + <refname>DomElement->remove_attribute</refname> + <refpurpose> + Adds new attribute + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomElement->remove_attribute</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomElement-get-elements-by-tagname'> + <refnamediv> + <refname>DomElement->get_elements_by_tagname</refname> + <refpurpose> + Adds new attribute + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomElement->get_elements_by_tagname</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomElement-has-attribute'> + <refnamediv> + <refname>DomElement->has_attribute</refname> + <refpurpose> + Adds new attribute + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomElement->has_attribute</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <!-- End of class DomElement --> + + <!-- Start of class DomNode --> + + <refentry id='function.DomNode-attributes'> + <refnamediv> + <refname>DomNode->attributes</refname> + <refpurpose> + Returns list of attributes + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>array</type><methodname>DomNode->attributes</methodname> + <void/> + </methodsynopsis> + <para> + This function only returns an array of attributes if the node is of + type XML_ELEMENT_NODE. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-node-name'> + <refnamediv> + <refname>DomNode->node_name</refname> + <refpurpose> + Returns name of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomNode->node_name</methodname> + <void/> + </methodsynopsis> + <para> + Returns name of the node. The name has different meanings + for the different types of nodes as illustrated in the following table. + <table> + <title>Meaning of value</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Type</entry> + <entry>Meaning</entry> + </row> + </thead> + <tbody> + <row> + <entry>DomAttribute</entry> + <entry>value of attribute</entry> + </row> + <row> + <entry>DomAttribute</entry> + <entry></entry> + </row> + <row> + <entry>DomCDataSection</entry> + <entry>#cdata-section</entry> + </row> + <row> + <entry>DomComment</entry> + <entry>#comment</entry> + </row> + <row> + <entry>DomDocument</entry> + <entry>#document</entry> + </row> + <row> + <entry>DomDocumentType</entry> + <entry>document type name</entry> + </row> + <row> + <entry>DomElement</entry> + <entry>tag name</entry> + </row> + <row> + <entry>DomEntity</entry> + <entry>name of entity</entry> + </row> + <row> + <entry>DomEntityReference</entry> + <entry>name of entity reference</entry> + </row> + <row> + <entry>DomNotation</entry> + <entry>notation name</entry> + </row> + <row> + <entry>DomProcessingInstruction</entry> + <entry>target</entry> + </row> + <row> + <entry>DomText</entry> + <entry>#text</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-node-value'> + <refnamediv> + <refname>DomNode->node_value</refname> + <refpurpose> + Returns value of a node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomNode->node_value</methodname> + <void/> + </methodsynopsis> + <para> + Returns value of the node. The value has different meanings + for the different types of nodes as illustrated in the following table. + <table> + <title>Meaning of value</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Type</entry> + <entry>Meaning</entry> + </row> + </thead> + <tbody> + <row> + <entry>DomAttribute</entry> + <entry>value of attribute</entry> + </row> + <row> + <entry>DomAttribute</entry> + <entry></entry> + </row> + <row> + <entry>DomCDataSection</entry> + <entry>content</entry> + </row> + <row> + <entry>DomComment</entry> + <entry>content of comment</entry> + </row> + <row> + <entry>DomDocument</entry> + <entry>null</entry> + </row> + <row> + <entry>DomDocumentType</entry> + <entry>null</entry> + </row> + <row> + <entry>DomElement</entry> + <entry>null</entry> + </row> + <row> + <entry>DomEntity</entry> + <entry>null</entry> + </row> + <row> + <entry>DomEntityReference</entry> + <entry>null</entry> + </row> + <row> + <entry>DomNotation</entry> + <entry>null</entry> + </row> + <row> + <entry>DomProcessingInstruction</entry> + <entry>entire content without target</entry> + </row> + <row> + <entry>DomText</entry> + <entry>content of text</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-node-type'> + <refnamediv> + <refname>DomNode->node_type</refname> + <refpurpose> + Returns type of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>int</type><methodname>DomNode->node_type</methodname> + <void/> + </methodsynopsis> + <para> + Returns the type of the node. All possible types are listed in + the table in the introduction. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-last-child'> + <refnamediv> + <refname>DomNode->last_child</refname> + <refpurpose> + Returns last child of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->last_child</methodname> + <void/> + </methodsynopsis> + <para> + Returns the last child of the node. + </para> + <para> + See also <function>DomNode_first_child</function>, + <function>DomNode_next_sibling</function>, + <function>DomNode_previous_sibling</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-first-child'> + <refnamediv> + <refname>DomNode->first_child</refname> + <refpurpose> + Returns first child of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomNode->first_child</methodname> + <void/> + </methodsynopsis> + <para> + Returns the first child of the node. + </para> + <para> + See also <function>DomNode_last_child</function>, + <function>DomNode_next_sibling</function>, + <function>DomNode_previous_sibling</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-child-nodes'> + <refnamediv> + <refname>DomNode->child-nodes</refname> + <refpurpose> + Returns children of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>array</type><methodname>DomNode->child_nodes</methodname> + <void/> + </methodsynopsis> + <para> + Returns all children of the node. + </para> + <para> + See also <function>DomNode_next_sibling</function>, + <function>DomNode_previous_sibling</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-previous-sibling'> + <refnamediv> + <refname>DomNode->previous_sibling</refname> + <refpurpose> + Returns the previous sibling of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->previous_sibling</methodname> + <void/> + </methodsynopsis> + <para> + This function returns the previous sibling of the current node. + </para> + <para> + See also <function>DomNode_next_sibling</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-next-sibling'> + <refnamediv> + <refname>DomNode->next_sibling</refname> + <refpurpose> + Returns the next sibling of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->next_sibling</methodname> + <void/> + </methodsynopsis> + <para> + This function returns the next sibling of the current node. If there is + no next sibling it returns false. You can use this function to iterate + over all children of a node as shown in the example. + </para> + <para> + <example> + <title>Iterate over children</title> + <programlisting role="php"> +<![CDATA[ +<?php +include("example.inc"); + +$elements = $dom->get_elements_by_tagname("tbody"); +$element = $elements[0]; +$child = $element->first_child(); + +while($child) { + print_r($child); + $child = $child->next_sibling(); +} +?> +]]> + </programlisting> + </example> + </para> + <para> + See also <function>DomNode_previous_sibling</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-parent-node'> + <refnamediv> + <refname>DomNode->parent_node</refname> + <refpurpose> + Returns the parent of the node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->parent_node</methodname> + <void/> + </methodsynopsis> + <para> + This function returns the parent node. + </para> + <para> + The following example will show two identical lists of children. + <example> + <title>Finding the document of a node</title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = domxml_new_xmldoc("1.0"); +$node = $doc->create_element("para"); +$node = $doc->append_child($node); +$children = $doc->children(); +print_r($children); + +$doc2 = $node->parent_node(); +$children = $doc2->children(); +print_r($children); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-owner-document'> + <refnamediv> + <refname>DomNode->owner_document</refname> + <refpurpose> + Returns the document this node belongs to + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->owner_document</methodname> + <void/> + </methodsynopsis> + <para> + This function returns the document the current node belongs to. + </para> + <para> + The following example will create two identical lists of children. + <example> + <title>Finding the document of a node</title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = domxml_new_xmldoc("1.0"); +$node = $doc->create_element("para"); +$node = $doc->append_child($node); +$children = $doc->children(); +print_r($children); + +$doc2 = $node->owner_document(); +$children = $doc2->children(); +print_r($children); +?> +]]> + </programlisting> + </example> + </para> + <para> + See also <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-insert-before'> + <refnamediv> + <refname>DomNode->insert_before</refname> + <refpurpose> + Inserts new node as child + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->insert_before</methodname> + <methodparam><type>object</type><parameter>newnode</parameter></methodparam> + <methodparam><type>object</type><parameter>refnode</parameter></methodparam> + </methodsynopsis> + <para> + This function inserts the new node <parameter>newnode</parameter> right + before the node <parameter>refnode</parameter>. + The return value is the + appended child. If you plan to do further modifications on the appended + child you must use the returned node. + </para> + <para> + See also <function>DomNode_append_child</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-append-child'> + <refnamediv> + <refname>DomNode->append_child</refname> + <refpurpose> + Adds new child at the end of the children + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>node</type><methodname>DomNode->append_child</methodname> + <methodparam><type>object</type><parameter>newnode</parameter></methodparam> + </methodsynopsis> + <para> + This functions appends a child to an existing list of children or creates + a new child. The child can be created with e.g. + <function>DomDocument_create_element</function>, + <function>DomDocument_create_text</function> etc. The return value is the + appended child. If you plan to do further modifications on the appended + child you must use the returned node. + </para> + <para> + <example> + <title>Adding a child</title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = domxml_new_xmldoc("1.0"); +$node = $doc->create_element("para"); +$node = $doc->append_child($node); +$node->set_attribute("align", "left"); +?> +]]> + </programlisting> + </example> + </para> + <para> + See also <function>DomNode_insert_before</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-has-child-nodes'> + <refnamediv> + <refname>DomNode->has_child_nodes</refname> + <refpurpose> + Checks if node has children + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomNode->has_child_nodes</methodname> + <void/> + </methodsynopsis> + <para> + This function checks if the node has children. + </para> + <para> + See also <function>DomNode_child_nodes</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-has-attributes'> + <refnamediv> + <refname>DomNode->has_attributess</refname> + <refpurpose> + Checks if node has attributes + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomNode->has_attributes</methodname> + <void/> + </methodsynopsis> + <para> + This function checks if the node has attributes. + </para> + <para> + See also <function>DomNode_has_child_nodes</function>. + </para> + </refsect1> + </refentry> + + <!-- End of class DomNode --> + + <!-- Start of class DomAttribute --> + + <refentry id='function.DomAttribute-name'> + <refnamediv> + <refname>DomAttribute->name</refname> + <refpurpose> + Returns name of attribute + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomAttribute->name</methodname> + <void/> + </methodsynopsis> + <para> + This function returns the name of the attribute. + </para> + <para> + See also <function>DomAttribute_value</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomAttribute-value'> + <refnamediv> + <refname>DomAttribute->value</refname> + <refpurpose> + Returns value of attribute + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomAttribute->value</methodname> + <void/> + </methodsynopsis> + <para> + This function returns the value of the attribute. + </para> + <para> + See also <function>DomAttribute_name</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomAttribute-specified'> + <refnamediv> + <refname>DomAttribute->specified</refname> + <refpurpose> + Checks if attribute is specified + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomAttribute->specified</methodname> + <void/> + </methodsynopsis> + <para> + Check DOM standard for a detailed explanation. + </para> + </refsect1> + </refentry> + + <!-- End of class DomAttribute --> + + <!-- Start of class DomDocumentType --> + + <refentry id='function.DomDocumentType-name'> + <refnamediv> + <refname>DomDocumentType->name</refname> + <refpurpose> + Returns name of document type + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomDocumentType->name</methodname> + <void/> + </methodsynopsis> + <para> + This function returns the name of the document type. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomDocumentType-entities'> + <refnamediv> + <refname>DomDocumentType->entities</refname> + <refpurpose> + Returns list of entities + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>array</type><methodname>DomDocumentType->entities</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomDocumentType-notations'> + <refnamediv> + <refname>DomDocumentType->notations</refname> + <refpurpose> + Returns list of notations + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>array</type><methodname>DomDocumentType->notations</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomDocumentType-public-id'> + <refnamediv> + <refname>DomDocumentType->public_id</refname> + <refpurpose> + Returns public id of document type + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomDocumentType->public_id</methodname> + <void/> + </methodsynopsis> + <para> + This function returns the public id of the document type. + </para> + <para> + The following example echos nothing. + <example> + <title>Retrieving the public id</title> + <programlisting role="php"> +<![CDATA[ +<?php +include("example.inc"); + +if(!$dom = xmldoc($xmlstr)) { + echo "Error while parsing the document\n"; + exit; +} + +$doctype = $dom->doctype(); +echo $doctype->public_id(); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id='function.DomDocumentType-system-id'> + <refnamediv> + <refname>DomDocumentType->system_id</refname> + <refpurpose> + Returns system id of document type + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomDocumentType->system_id</methodname> + <void/> + </methodsynopsis> + <para> + Returns the system id of the document type. + </para> + <para> + The following example echos + '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'. + <example> + <title>Retrieving the system id</title> + <programlisting role="php"> +<![CDATA[ +<?php +include("example.inc"); + +if(!$dom = xmldoc($xmlstr)) { + echo "Error while parsing the document\n"; + exit; +} + +$doctype = $dom->doctype(); +echo $doctype->system_id(); +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id='function.DomDocumentType-internal-subset'> + <refnamediv> + <refname>DomDocumentType->internal_subset</refname> + <refpurpose> + Returns internal subset + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomDocumentType->internal_subset</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <!-- End of class DomDocumentType --> + + <!-- Start of class XPathContext --> + <!-- End of class XPathContext --> + + <refentry id='function.domxml-node'> + <refnamediv> + <refname>domxml_node</refname> + <refpurpose> + Creates node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>domxml_node</methodname> + <methodparam><type>string</type><parameter>name</parameter></methodparam> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.domxml-node-set-content'> + <refnamediv> + <refname>domxml_node_set_content</refname> + <refpurpose> + Sets content of a node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>domxml_node_set_content</methodname> + <methodparam><type>string</type><parameter>content</parameter></methodparam> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.domxml-node-unlink-node'> + <refnamediv> + <refname>domxml_node_unlink_node</refname> + <refpurpose> + Deletes node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>domxml_node_unlink_node</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id="function.xpath-eval-expression"> + <refnamediv> + <refname>xpath_eval_expression</refname> + <refpurpose> + Evaluates the XPath Location Path in the given string + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>array</type><methodname>xpath_eval_expression</methodname> + +<methodparam><type>object</type><parameter>xpath_context</parameter></methodparam> + </methodsynopsis> + &warn.experimental.func; + <para> + </para> + <para> + See also <function>xpath_eval</function> + </para> + </refsect1> + </refentry> + + <refentry id='function.domxml-version'> + <refnamediv> + <refname>domxml_version</refname> + <refpurpose> + Get XML library version + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>domxml_version</methodname> + <void/> + </methodsynopsis> <para> This function returns the version of the XML library version currently used. </para>