steinm Fri Apr 12 07:20:15 2002 EDT Modified files: /phpdoc/en/functions domxml.xml Log: - even more documentation (most functions should be documented now)
Index: phpdoc/en/functions/domxml.xml diff -u phpdoc/en/functions/domxml.xml:1.38 phpdoc/en/functions/domxml.xml:1.39 --- phpdoc/en/functions/domxml.xml:1.38 Thu Apr 11 11:46:57 2002 +++ phpdoc/en/functions/domxml.xml Fri Apr 12 07:20:13 2002 @@ -1,40 +1,146 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.38 $ --> +<!-- $Revision: 1.39 $ --> <reference id="ref.domxml"> <title>DOM XML functions</title> <titleabbrev>DOM XML</titleabbrev> <partintro> - <sect1 id="domxml-intro"> <title>Introduction</title> &warn.experimental; <para> - This documentation is not finished yet. Don't start to translate it - or use it as a programming reference ([EMAIL PROTECTED]). + The domxml extension has been overhauled in PHP Version 4.3.0 in favour + of a better compliance of the DOM standard. The extension still contains + many old functions, but they should not be used anymore. Especially those + non object oriented functions should be avoided. </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 + It also provides a function <function>domxml_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 + would not make any sense since <function>DomDocument_dump_mem</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. + <function>DomDocument_dump_mem</function> functions. </para> </sect1> <sect1 id="domxml-requirements"> <title>Requirements</title> <para> - These functions are only available if PHP was configured with + This extension is 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. + </para> + </sect1> + + <sect1 id="domxml-deprecated"> + <title>Deprecated functions</title> + <para> + <table> + <title>Deprecated functions and its replacements</title> + <tgroup cols="2"> + <thead> + <row> + <entry>Old function</entry> + <entry>New function</entry> + </row> + </thead> + <tbody> + <row> + <entry>xmldoc</entry> + <entry><function>domxml_open_mem</function></entry> + </row> + <row> + <entry>xmldocfiel</entry> + <entry><function>domxml_open_file</function></entry> + </row> + <row> + <entry>domxml_new_xmldoc</entry> + <entry><function>domxml_new_doc</function></entry> + </row> + <row> + <entry>domxml_dump_mem</entry> + <entry><function>DomDocument_dump_mem</function></entry> + </row> + <row> + <entry>domxml_dump_mem_file</entry> + <entry><function>DomDocument_dump_file</function></entry> + </row> + <row> + <entry>DomDocument_dump_mem_file</entry> + <entry><function>DomDocument_dump_file</function></entry> + </row> + <row> + <entry>DomDocument_add_root</entry> + <entry><function>DomDocument_create_element</function> followed by + <function>DomNode_append_child</function></entry> + </row> + <row> + <entry>DomDocument_dtd</entry> + <entry><function>DomDocument_doctype</function></entry> + </row> + <row> + <entry>DomDocument_root</entry> + <entry><function>DomDocument_document_element</function></entry> + </row> + <row> + <entry>DomDocument_children</entry> + <entry><function>DomNode_child_nodes</function></entry> + </row> + <row> + <entry>DomDocument_imported_node</entry> + <entry>No replacement.</entry> + </row> + <row> + <entry>DomNode_add_child</entry> + <entry>Create a new node with e.g. + <function>DomDocument_create_element</function> und add it with + <function>DomNode_append_child</function>. + </entry> + </row> + <row> + <entry>DomNode_children</entry> + <entry><function>DomNode_child_nodes</function></entry> + </row> + <row> + <entry>DomNode_parent</entry> + <entry><function>DomNode_parent_node</function></entry> + </row> + <row> + <entry>DomNode_new_child</entry> + <entry>Create a new node with e.g. + <function>DomDocument_create_element</function> und add it with + <function>DomNode_append_child</function>. + </entry> + </row> + <row> + <entry>DomNode_set_content</entry> + <entry>Create a new node with e.g. + <function>DomDocument_create_text_node</function> und add it with + <function>DomNode_append_child</function>. + </entry> + </row> + <row> + <entry>DomNode_get_content</entry> + <entry>Content is just a text node and can be accessed with + <function>DomNode_child_nodes</function>. + </entry> + </row> + <row> + <entry>DomNode_set_content</entry> + <entry>Content is just a text node and can be added with + <function>DomNode_append_child</function>. + </entry> + </row> + </tbody> + </tgroup> + </table> </para> </sect1> @@ -207,11 +313,11 @@ <entry>DomCData : DomNode</entry> </row> <row> - <entry>DomParser</entry> - <entry></entry> + <entry>Parser</entry> + <entry>Currently still called DomParser</entry> </row> <row> - <entry>XPathContext<function>></function></entry> + <entry>XPathContext</entry> <entry></entry> </row> </tbody> @@ -227,14 +333,14 @@ <row> <entry>Method name</entry> <entry>Function name</entry> - <entry>Description</entry> + <entry>Remark</entry> </row> </thead> <tbody> <row> <entry>doctype</entry> <entry><function>DomDocument_doctype</function></entry> - <entry>Returns the document type</entry> + <entry></entry> </row> <row> <entry>document_elemnent</entry> @@ -287,34 +393,34 @@ <entry></entry> </row> <row> - <entry>add_root</entry> - <entry><function>domxml_add_root</function></entry> - <entry></entry> + <entry>dump_mem</entry> + <entry><function>DomDocument_dump_mem</function></entry> + <entry>not DOM standard</entry> </row> <row> - <entry>dtd</entry> - <entry><function>domxml_intdtd</function></entry> - <entry></entry> + <entry>dump_file</entry> + <entry><function>DomDocument_dump_file</function></entry> + <entry>not DOM standard</entry> </row> <row> - <entry>dumpmem</entry> - <entry><function>domxml</function></entry> - <entry></entry> + <entry>html_dump_mem</entry> + <entry><function>DomDocument_html_dump_mem</function></entry> + <entry>not DOM standard</entry> </row> <row> <entry>xpath_init</entry> <entry>xpath_init</entry> - <entry></entry> + <entry>not DOM standard</entry> </row> <row> <entry>xpath_new_context</entry> <entry>xpath_new_context</entry> - <entry></entry> + <entry>not DOM standard</entry> </row> <row> <entry>xptr_new_context</entry> <entry>xptr_new_context</entry> - <entry></entry> + <entry>not DOM standard</entry> </row> </tbody> </tgroup> @@ -329,7 +435,7 @@ <row> <entry>Method name</entry> <entry>Function name</entry> - <entry>Description</entry> + <entry>Remark</entry> </row> </thead> <tbody> @@ -385,7 +491,7 @@ <thead> <row> <entry>Method name</entry> - <entry>Description</entry> + <entry>Remark</entry> </row> </thead> <tbody> @@ -446,27 +552,35 @@ <entry></entry> </row> <row> - <entry>new_child</entry> - <entry>Not in DOM standard</entry> + <entry><function>DomNode_clone_node</function></entry> + <entry></entry> </row> <row> - <entry>get_attribute</entry> + <entry><function>DomNode_attributes</function></entry> + <entry></entry> + </row> + <row> + <entry><function>DomNode_unlink_node</function></entry> <entry>Not in DOM standard</entry> </row> <row> - <entry>set_attribute</entry> + <entry><function>DomNode_replace_node</function></entry> <entry>Not in DOM standard</entry> </row> <row> - <entry>DomNode_attributes</entry> - <entry></entry> + <entry><function>DomNode_set_content</function></entry> + <entry>Not in DOM standard, deprecated</entry> + </row> + <row> + <entry><function>DomNode_get_content</function></entry> + <entry>Not in DOM standard, deprecated</entry> </row> <row> - <entry>node</entry> + <entry><function>DomNode_dump_node</function></entry> <entry>Not in DOM standard</entry> </row> <row> - <entry><function>set_content</function></entry> + <entry><function>DomNode_is_blank_node</function></entry> <entry>Not in DOM standard</entry> </row> </tbody> @@ -482,7 +596,7 @@ <row> <entry>Method name</entry> <entry></entry> - <entry>Description</entry> + <entry>Remark</entry> </row> </thead> <tbody> @@ -514,7 +628,7 @@ <row> <entry>Method name</entry> <entry>Function name</entry> - <entry>Description</entry> + <entry>Remark</entry> </row> </thead> <tbody> @@ -535,24 +649,24 @@ <para> <table> - <title>DomParser class</title> + <title>Parser class</title> <tgroup cols="3"> <thead> <row> <entry>Method name</entry> <entry>Function name</entry> - <entry>Description</entry> + <entry>Remark</entry> </row> </thead> <tbody> <row> <entry>add_chunk</entry> - <entry><function>DomParser_add_chunk</function></entry> + <entry><function>Parser_add_chunk</function></entry> <entry></entry> </row> <row> <entry>end</entry> - <entry><function>DomParser_end</function></entry> + <entry><function>Parser_end</function></entry> <entry></entry> </row> </tbody> @@ -568,7 +682,7 @@ <row> <entry>Method name</entry> <entry>Function name</entry> - <entry>Description</entry> + <entry>Remark</entry> </row> </thead> <tbody> @@ -600,7 +714,7 @@ <row> <entry>Method name</entry> <entry>Function name</entry> - <entry>Description</entry> + <entry>Remark</entry> </row> </thead> <tbody> @@ -651,7 +765,10 @@ 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. + following example section. You could also create an xml document + read it with <function>DomDocument_open_file</function>. + </para> + <para> <example> <title>Include file example.inc with xml string</title> <programlisting role="php"> @@ -686,68 +803,130 @@ </sect1> </partintro> - <refentry id="function.xmldoc"> + <refentry id="function.domxml-open-mem"> <refnamediv> - <refname>xmldoc</refname> + <refname>domxml_open_mem</refname> <refpurpose>Creates a DOM object of an XML document</refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>xmldoc</methodname> - <methodparam><type>string</type><parameter>str</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; + <methodsynopsis> + <type>object</type><methodname>domxml_open_mem</methodname> + <methodparam><type>string</type><parameter>str</parameter></methodparam> + </methodsynopsis> <para> The function parses the XML document in <parameter>str</parameter> and returns an object of class "Dom - document", having the properties as listed above. + document", having the properties as listed above. This function, + <function>domxml_open_file</function> or <function>domxml_new_doc</function> + must be called before any other function calls. + </para> + <para> + <example> + <title>Opening a xml document in a string</title> + <programlisting role="php"> +<![CDATA[ +<?php +include("example.inc"); + +if(!$dom = domxml_open_mem($xmlstr)) { + echo "Error while parsing the document\n"; + exit; +} + +$root = $dom->document_element(); +?> +]]> + </programlisting> + </example> + </para> + <para> + See also <function>domxml_open_file</function>, + <function>domxml_new_doc</function>. </para> - <simpara> - See also <function>xmldocfile</function> - </simpara> </refsect1> </refentry> - <refentry id="function.xmldocfile"> + <refentry id="function.domxml-open-file"> <refnamediv> - <refname>xmldocfile</refname> + <refname>domxml_open_file</refname> <refpurpose>Creates a DOM object from XML file</refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>xmldocfile</methodname> - <methodparam><type>string</type><parameter>filename</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; + <methodsynopsis> + <type>object</type><methodname>domxml_open_file</methodname> + <methodparam><type>string</type><parameter>filename</parameter></methodparam> + </methodsynopsis> <para> The function parses the XML document in the file named <parameter>filename</parameter> and returns an object of class "Dom document", having the properties as listed above. The file is accessed read-only. </para> - <simpara> - See also <function>xmldoc</function> - </simpara> + <para> + <example> + <title>Opening a xml document from a file</title> + <programlisting role="php"> +<![CDATA[ +<?php + +if(!$dom = domxml_open_file("example.xml")) { + echo "Error while parsing the document\n"; + exit; +} + +$root = $dom->document_element(); +?> +]]> + </programlisting> + </example> + </para> + <para> + See also <function>domxml_open_mem</function>, + <function>domxml_new_doc</function>. + </para> </refsect1> </refentry> - <refentry id="function.xmltree"> + <refentry id="function.domxml-new-doc"> <refnamediv> - <refname>xmltree</refname> + <refname>domxml_new_doc</refname> <refpurpose> - Creates a tree of PHP objects from an XML document + Creates new empty XML document </refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> - <type>object</type><methodname>xmltree</methodname> - <methodparam><type>string</type><parameter>str</parameter></methodparam> + <type>object</type><methodname>domxml_new_doc</methodname> + <methodparam><type>string</type><parameter>version</parameter></methodparam> </methodsynopsis> &warn.experimental.func; <para> + Creates a new dom document from scratch and returns it. + </para> + <para> + See also <function>DomDocument_add_root</function> + </para> + </refsect1> + </refentry> + + <refentry id="function.domxml-xmltree"> + <refnamediv> + <refname>domxml_xmltree</refname> + <refpurpose> + Creates a tree of PHP objects from an XML document + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>domxml_xmltree</methodname> + <methodparam><type>string</type><parameter>str</parameter></methodparam> + </methodsynopsis> + &warn.experimental.func; + <para> The function parses the XML document in <parameter>str</parameter> and returns a tree PHP objects as the parsed document. This function is isolated from the other functions, @@ -760,6 +939,25 @@ </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> + </refsect1> + </refentry> + <!-- Start of class DomDocument --> <refentry id="function.DomDocument-doctype"> @@ -813,7 +1011,7 @@ <?php include("example.inc"); -if(!$dom = xmldoc($xmlstr)) { +if(!$dom = domxml_open_mem($xmlstr)) { echo "Error while parsing the document\n"; exit; } @@ -1092,7 +1290,7 @@ <para> </para> <para> - See also <function>domxml_add_root</function> + See also <function>DomDocument_add_root</function> </para> </refsect1> </refentry> @@ -1112,31 +1310,30 @@ <para> </para> <para> - See also <function>domxml_add_root</function> + See also <function>DomDocument_add_root</function> </para> </refsect1> </refentry> <!-- End of class DomDocument --> - <refentry id="function.domxml-add-root"> + <refentry id="function.DomDocument-add-root"> <refnamediv> - <refname>domxml_add_root</refname> + <refname>DomDocument->add_root [deprecated]</refname> <refpurpose> - Adds a further root node + Adds a root node </refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> - <type>resource</type><methodname>domxml_add_root</methodname> - <methodparam><type>resource</type><parameter>doc</parameter></methodparam> + <type>resource</type><methodname>DomDocument->add_root</methodname> <methodparam><type>string</type><parameter>name</parameter></methodparam> </methodsynopsis> &warn.experimental.func; <para> Adds a root element node to a dom document and returns the new node. - The element name is given in the second parameter. + The element name is given in the passed parameter. </para> <para> <example> @@ -1144,11 +1341,11 @@ <programlisting role="php"> <![CDATA[ <?php -$doc = new_xmldoc("1.0"); +$doc = domxml_new_doc("1.0"); $root = $doc->add_root("HTML"); $head = $root->new_child("HEAD", ""); $head->new_child("TITLE", "Hier der Titel"); -echo $doc->dumpmem(); +echo htmlentities($doc->dump_mem()); ?> ]]> </programlisting> @@ -1157,9 +1354,9 @@ </refsect1> </refentry> - <refentry id="function.domxml-dumpmem"> + <refentry id="function.DomDocument-dump-mem"> <refnamediv> - <refname>domxml_dumpmem</refname> + <refname>DomDocument->dump_mem</refname> <refpurpose> Dumps the internal XML tree back into a string </refpurpose> @@ -1167,271 +1364,177 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>string</type><methodname>domxml_dumpmem</methodname> - <methodparam><type>resource</type><parameter>doc</parameter></methodparam> + <type>string</type><methodname>DomDocument->dump_mem</methodname> <methodparam choice="opt"><type>bool</type><parameter>format</parameter></methodparam> </methodsynopsis> &warn.experimental.func; <para> Creates an XML document from the dom representation. This function - usually is called after a building a new dom document from scratch - as in the example of <function>domxml_add_root</function>. The - <parameter>format</parameter> specifies whether the output should be neatly - formatted, or not. + usually is called after building a new dom document from scratch + as in the example below. The + <parameter>format</parameter> specifies whether the output should be + neatly formatted, or not. + </para> + <para> + <example> + <title>Creating a simple HTML document header</title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = domxml_new_doc("1.0"); +$root = $doc->create_element("HTML"); +$root = $doc->append_child($root); +$head = $doc->create_element("HEAD"); +$head = $root->append_child($head); +$title = $doc->create_element("TITLE"); +$title = $head->append_child($title); +$text = $doc->create_text_node("This is the title"); +$text = $title->append_child($text); +echo "<PRE>"; +echo htmlentities($doc->dump_mem(true)); +echo "</PRE>"; +?> +]]> + </programlisting> + </example> </para> <note> <para> - The second parameter was added in PHP 4.3.0. + The first parameter was added in PHP 4.3.0. </para> </note> <para> - See also <function>domxml_add_root</function> - </para> - </refsect1> - </refentry> - - <refentry id="function.domxml-attributes"> - <refnamediv> - <refname>domxml_attributes</refname> - <refpurpose> - Returns an array of attributes of a node - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <methodsynopsis> - <type>array</type><methodname>domxml_attributes</methodname> - <methodparam><type>resource</type><parameter>node</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; - <para> - Returns all attributes of a node as array of objects of type - "dom attribute". - </para> - </refsect1> - </refentry> - - <refentry id="function.domxml-get-attribute"> - <refnamediv> - <refname>domxml_get_attribute</refname> - <refpurpose> - Returns a certain attribute of a node - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>domxml_get_attribute</methodname> - <methodparam><type>resource</type><parameter>node</parameter></methodparam> - <methodparam><type>string</type><parameter>name</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; - <para> - Returns the attribute with name <parameter>name</parameter> of the given - node. + See also <function>DomDocument_dump_file</function>, + <function>DomDocument_html_dump_mem</function>. </para> - <simpara> - See also <function>domxml_set_attribute</function> - </simpara> </refsect1> </refentry> - <refentry id="function.domxml-set-attribute"> + <refentry id="function.DomDocument-dump-file"> <refnamediv> - <refname>domxml_set_attribute</refname> + <refname>DomDocument->dump_file</refname> <refpurpose> + Dumps the internal XML tree back into a file </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>domxml_set_attribute</methodname> - <methodparam><type>resource</type><parameter>node</parameter></methodparam> - <methodparam><type>string</type><parameter>name</parameter></methodparam> - <methodparam><type>string</type><parameter>value</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; + <methodsynopsis> + <type>string</type><methodname>DomDocument->dump_file</methodname> + <methodparam><type>string</type><parameter>filename</parameter></methodparam> + <methodparam +choice="opt"><type>bool</type><parameter>compressionmode</parameter></methodparam> + <methodparam +choice="opt"><type>bool</type><parameter>format</parameter></methodparam> + </methodsynopsis> <para> - Sets an attribute with name <parameter>name</parameter> of the given - node on a value. + Creates an XML document from the dom representation. This function + usually is called after building a new dom document from scratch + as in the example below. The + <parameter>format</parameter> specifies whether the output should be + neatly formatted, or not. The first parameter specifies the name of the + filename and the second parameter, whether it should be compressed or not. </para> <para> - If we take the example from <function>domxml_add_root</function> it - is simple to add an attribute to the HEAD element by the simply calling - the <function>set_attribute</function> function of the node class. <example> - <title>Adding an attribute to an element</title> + <title>Creating a simple HTML document header</title> <programlisting role="php"> <![CDATA[ <?php -$doc = new_xmldoc("1.0"); -$root = $doc->add_root("HTML"); -$head = $root->new_child("HEAD", ""); -$head->new_child("TITLE", "Hier der Titel"); -$head->set_attribute("Language", "ge"); -echo $doc->dumpmem(); +$doc = domxml_new_doc("1.0"); +$root = $doc->create_element("HTML"); +$root = $doc->append_child($root); +$head = $doc->create_element("HEAD"); +$head = $root->append_child($head); +$title = $doc->create_element("TITLE"); +$title = $head->append_child($title); +$text = $doc->create_text_node("This is the title"); +$text = $title->append_child($text); +$doc->dump_file("/tmp/test.xml", false, true); ?> ]]> </programlisting> </example> </para> + <para> + See also <function>DomDocument_dump_mem</function> + <function>DomDocument_html_dump_mem</function>. + </para> </refsect1> </refentry> - <refentry id="function.domxml-children"> + <refentry id="function.DomDocument-html-dump-mem"> <refnamediv> - <refname>domxml_children</refname> + <refname>DomDocument->html_dump_mem</refname> <refpurpose> - Returns children of a node or document + Dumps the internal XML tree back into a string as HTML </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>array</type><methodname>domxml_children</methodname> - <methodparam><type>object</type><parameter>doc|node</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; + <methodsynopsis> + <type>string</type><methodname>DomDocument->html_dump_mem</methodname> + <void/> + </methodsynopsis> <para> - Returns all children of a node as an array of nodes. + Creates an HTML document from the dom representation. This function + usually is called after building a new dom document from scratch + as in the example below. </para> <para> - In the following example the variable <varname>children</varname> will - contain an array with one node of type XML_ELEMENT. This node is - the TITLE element. <example> - <title>Adding an attribute to an element</title> + <title>Creating a simple HTML document header</title> <programlisting role="php"> <![CDATA[ <?php -$doc = new_xmldoc("1.0"); -$root = $doc->add_root("HTML"); -$head = $root->new_child("HEAD", ""); -$head->new_child("TITLE", "Hier der Titel"); -$head->set_attribute("Language", "ge"); -$children = $head->children(); +$doc = domxml_new_doc("1.0"); +$root = $doc->create_element("HTML"); +$root = $doc->append_child($root); +$head = $doc->create_element("HEAD"); +$head = $root->append_child($head); +$title = $doc->create_element("TITLE"); +$title = $head->append_child($title); +$text = $doc->create_text_node("This is the title"); +$text = $title->append_child($text); +echo "<PRE>"; +echo htmlentities($doc->html_dump_mem()); +echo "</PRE>"; ?> ]]> </programlisting> </example> </para> + <para> + See also <function>DomDocument_dump_file</function>, + <function>DomDocument_html_dump_mem</function>. + </para> </refsect1> </refentry> - <refentry id="function.domxml-new-child"> + <!-- Start of class DomElement --> + + <refentry id='function.DomElement-tagname'> <refnamediv> - <refname>domxml_new_child</refname> + <refname>DomElement->tagname</refname> <refpurpose> - Adds new child node + Returns name of element </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>resource</type><methodname>domxml_new_child</methodname> - <methodparam><type>string</type><parameter>name</parameter></methodparam> - <methodparam><type>string</type><parameter>content</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; + <methodsynopsis> + <type>string</type><methodname>DomElement->tagname</methodname> + <void/> + </methodsynopsis> <para> - Adds a new child of type element to a node and returns it. + &warn.undocumented.func; </para> </refsect1> </refentry> - <refentry id="function.domxml-new-xmldoc"> + <refentry id='function.DomElement-get-attribute'> <refnamediv> - <refname>domxml_new_xmldoc</refname> + <refname>DomElement->get_attribute</refname> <refpurpose> - Creates new empty XML document - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>domxml_new_xmldoc</methodname> - <methodparam><type>string</type><parameter>version</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; - <para> - Creates a new dom document from scratch and returns it. - </para> - <para> - See also <function>domxml_add_root</function> - </para> - </refsect1> - </refentry> - - <refentry id="function.xpath-new-context"> - <refnamediv> - <refname>xpath_new_context</refname> - <refpurpose> - Creates new xpath context - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>xpath_new_context</methodname> - <methodparam><type>object</type><parameter>dom document</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; - <para> - </para> - <para> - See also <function>xpath_eval</function> - </para> - </refsect1> - </refentry> - - <refentry id="function.xpath-eval"> - <refnamediv> - <refname>xpath_eval</refname> - <refpurpose> - Evaluates the XPath Location Path in the given string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <methodsynopsis> - <type>array</type><methodname>xpath_eval</methodname> - <methodparam><type>object</type><parameter>xpath context</parameter></methodparam> - </methodsynopsis> - &warn.experimental.func; - <para> - </para> - <para> - See also <function>xpath_new_context</function> - </para> - </refsect1> - </refentry> - - <!-- Start of class DomElement --> - - <refentry id='function.DomElement-tagname'> - <refnamediv> - <refname>DomElement->tagname</refname> - <refpurpose> - Returns name of element - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <methodsynopsis> - <type>string</type><methodname>DomElement->tagname</methodname> - <void/> - </methodsynopsis> - <para> - &warn.undocumented.func; - </para> - </refsect1> - </refentry> - - <refentry id='function.DomElement-get-attribute'> - <refnamediv> - <refname>DomElement->get_attribute</refname> - <refpurpose> - Returns value of attribute + Returns value of attribute </refpurpose> </refnamediv> <refsect1> @@ -1441,7 +1544,11 @@ <methodparam><type>string</type><parameter>name</parameter></methodparam> </methodsynopsis> <para> - &warn.undocumented.func; + Returns the attribute with name <parameter>name</parameter> of the + current node. + </para> + <para> + See also <function>DomElement_set_attribute</function> </para> </refsect1> </refentry> @@ -1461,7 +1568,26 @@ <methodparam><type>string</type><parameter>value</parameter></methodparam> </methodsynopsis> <para> - &warn.undocumented.func; + Sets an attribute with name <parameter>name</parameter> ot the given + value. If the attribute does not exist, it will be created. + </para> + <para> + <example> + <title>Setting an attribute</title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = domxml_new_doc("1.0"); +$node = $doc->create_element("para"); +$newnode = $doc->append_child($node); +$newnode->set_attribute("align", "left"); +?> +]]> + </programlisting> + </example> + </para> + <para> + See also <function>DomElement_get_attribute</function> </para> </refsect1> </refentry> @@ -1928,7 +2054,7 @@ <programlisting role="php"> <![CDATA[ <?php -$doc = domxml_new_xmldoc("1.0"); +$doc = domxml_new_doc("1.0"); $node = $doc->create_element("para"); $node = $doc->append_child($node); $children = $doc->children(); @@ -1968,7 +2094,7 @@ <programlisting role="php"> <![CDATA[ <?php -$doc = domxml_new_xmldoc("1.0"); +$doc = domxml_new_doc("1.0"); $node = $doc->create_element("para"); $node = $doc->append_child($node); $children = $doc->children(); @@ -2004,12 +2130,40 @@ </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 + before the node <parameter>refnode</parameter>. The return value is the + inserted node. If you plan to do further modifications on the appended child you must use the returned node. </para> <para> + <function>DomNode_insert_before</function> is very similar to + <function>DomNode_append_child</function> as the following example shows + which does the same as the example at + <function>DomNode_append_child</function>. + </para> + <para> + <example> + <title>Adding a child</title> + <programlisting role="php"> +<![CDATA[ +include("example.inc"); + +$elements = $dom->get_elements_by_tagname("informaltable"); +print_r($elements); +$element = $elements[0]; + +$newnode = $element->insert_before($element, $element); +$children = $newnode->children(); +$attr = $children[1]->set_attribute("align", "left"); + +echo "<PRE>"; +$xmlfile = $dom->dump_mem(); +echo htmlentities($xmlfile); +echo "</PRE>"; +]]> + </programlisting> + </example> + </para> + <para> See also <function>DomNode_append_child</function>. </para> </refsect1> @@ -2030,26 +2184,79 @@ </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. + a new list of children. The child can be created with e.g. <function>DomDocument_create_element</function>, - <function>DomDocument_create_text</function> etc. The return value is the + <function>DomDocument_create_text</function> etc. or simply by using any + other node. + </para> + <para> + Before a new child is appended it is first duplicated. Therefore the new + child is a completely new copy which can be modified without changing the + node which was passed to this function. If the node passed has children + itself, they will be duplicated as well, which makes it quite easy to + duplicate large parts of a xml document. 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> + The following example will add a new element node to a fresh document + and sets the attribute "align" to "left". <example> <title>Adding a child</title> <programlisting role="php"> <![CDATA[ <?php -$doc = domxml_new_xmldoc("1.0"); +$doc = domxml_new_doc("1.0"); +$node = $doc->create_element("para"); +$newnode = $doc->append_child($node); +$newnode->set_attribute("align", "left"); +?> +]]> + </programlisting> + </example> + The above example could also be written as the following: + <example> + <title>Adding a child</title> + <programlisting role="php"> +<![CDATA[ +<?php +$doc = domxml_new_doc("1.0"); $node = $doc->create_element("para"); -$node = $doc->append_child($node); $node->set_attribute("align", "left"); +$newnode = $doc->append_child($node); ?> ]]> </programlisting> </example> + A more comples example is the one below. It first searches for a certain + element, duplicates it including its children and adds it as a sibling. + Finally a new attribute is added to one of the children of the new + sibling and the whole document is dumped. + <example> + <title>Adding a child</title> + <programlisting role="php"> +<![CDATA[ +include("example.inc"); + +$elements = $dom->get_elements_by_tagname("informaltable"); +print_r($elements); +$element = $elements[0]; + +$parent = $element->parent_node(); +$newnode = $parent->append_child($element); +$children = $newnode->children(); +$attr = $children[1]->set_attribute("align", "left"); + +echo "<PRE>"; +$xmlfile = $dom->dump_mem(); +echo htmlentities($xmlfile); +echo "</PRE>"; +]]> + </programlisting> + </example> + The above example could also be done with + <function>DomNode_insert_before</function> instead of + <function>DomNode_append_child</function>. </para> <para> See also <function>DomNode_insert_before</function>. @@ -2101,6 +2308,183 @@ </refsect1> </refentry> + <refentry id='function.DomNode-prefix'> + <refnamediv> + <refname>DomNode->prefix</refname> + <refpurpose> + Returns name space prefix of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomNode->prefix</methodname> + <void/> + </methodsynopsis> + <para> + Returns the name space prefix of the node. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-clone-node'> + <refnamediv> + <refname>DomNode->clone_node</refname> + <refpurpose> + Clones a node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->clone_node</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-unlink-node'> + <refnamediv> + <refname>DomNode->unlink_node</refname> + <refpurpose> + Deletes node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->unlink_node</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-replace-node'> + <refnamediv> + <refname>DomNode->replace_node</refname> + <refpurpose> + Replaces node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>object</type><methodname>DomNode->replace_node</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-set-content'> + <refnamediv> + <refname>DomNode->set_content</refname> + <refpurpose> + Sets content of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomNode->set_content</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-get-content'> + <refnamediv> + <refname>DomNode->get_content</refname> + <refpurpose> + Gets content of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomNode->get_content</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-dump-node'> + <refnamediv> + <refname>DomNode->dump_node</refname> + <refpurpose> + Dumps a single node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>string</type><methodname>DomNode->dump_node</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + <para> + See also <function>DomDocument_dump_mem</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-set-name'> + <refnamediv> + <refname>DomNode->set_name</refname> + <refpurpose> + Sets name of node + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomNode->set_name</methodname> + <void/> + </methodsynopsis> + <para> + Sets name of node. + </para> + <para> + See also <function>DomNode_node_name</function>. + </para> + </refsect1> + </refentry> + + <refentry id='function.DomNode-is-blank-node'> + <refnamediv> + <refname>DomNode->is_blank_node</refname> + <refpurpose> + Checks if node is blank + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <methodsynopsis> + <type>bool</type><methodname>DomNode->is_blank_node</methodname> + <void/> + </methodsynopsis> + <para> + &warn.undocumented.func; + </para> + </refsect1> + </refentry> + <!-- End of class DomNode --> <!-- Start of class DomAttribute --> @@ -2254,7 +2638,7 @@ <?php include("example.inc"); -if(!$dom = xmldoc($xmlstr)) { +if(!$dom = domxml_open_mem($xmlstr)) { echo "Error while parsing the document\n"; exit; } @@ -2295,7 +2679,7 @@ <?php include("example.inc"); -if(!$dom = xmldoc($xmlstr)) { +if(!$dom = domxml_open_mem($xmlstr)) { echo "Error while parsing the document\n"; exit; } @@ -2331,69 +2715,76 @@ <!-- End of class DomDocumentType --> - <!-- Start of class XPathContext --> - <!-- End of class XPathContext --> + <!-- Start of class DomProcessingInstruction --> - <refentry id='function.domxml-node'> + <refentry id='function.DomProcessingInstruction-target'> <refnamediv> - <refname>domxml_node</refname> + <refname>DomProcessingInstruction->target</refname> <refpurpose> - Creates node + Returns target of pi node </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>DomProcessingInstruction->target</methodname> + <void/> + </methodsynopsis> <para> &warn.undocumented.func; </para> </refsect1> </refentry> - <refentry id='function.domxml-node-set-content'> + <refentry id='function.DomProcessingInstruction-data'> <refnamediv> - <refname>domxml_node_set_content</refname> + <refname>DomProcessingInstruction->data</refname> <refpurpose> - Sets content of a node + Returns data of pi 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> + <methodsynopsis> + <type>string</type><methodname>DomProcessingInstruction->data</methodname> + <void/> + </methodsynopsis> <para> &warn.undocumented.func; </para> </refsect1> </refentry> - <refentry id='function.domxml-node-unlink-node'> + <!-- End of class DomProcessingInstruction --> + + <!-- Start of class XPathContext --> + <!-- End of class XPathContext --> + + <refentry id="function.xpath-new-context"> <refnamediv> - <refname>domxml_node_unlink_node</refname> + <refname>xpath_new_context</refname> <refpurpose> - Deletes node + Creates new xpath context </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>object</type><methodname>domxml_node_unlink_node</methodname> - <void/> - </methodsynopsis> + <methodsynopsis> + <type>object</type><methodname>xpath_new_context</methodname> + <methodparam><type>object</type><parameter>dom +document</parameter></methodparam> + </methodsynopsis> + &warn.experimental.func; <para> - &warn.undocumented.func; + </para> + <para> + See also <function>xpath_eval</function> </para> </refsect1> </refentry> - <refentry id="function.xpath-eval-expression"> + <refentry id="function.xpath-eval"> <refnamediv> - <refname>xpath_eval_expression</refname> + <refname>xpath_eval</refname> <refpurpose> Evaluates the XPath Location Path in the given string </refpurpose> @@ -2401,33 +2792,36 @@ <refsect1> <title>Description</title> <methodsynopsis> - <type>array</type><methodname>xpath_eval_expression</methodname> - <methodparam><type>object</type><parameter>xpath_context</parameter></methodparam> + <type>array</type><methodname>xpath_eval</methodname> + <methodparam><type>object</type><parameter>xpath +context</parameter></methodparam> </methodsynopsis> - &warn.experimental.func; + &warn.experimental.func; <para> </para> <para> - See also <function>xpath_eval</function> + See also <function>xpath_new_context</function> </para> </refsect1> </refentry> - <refentry id='function.domxml-version'> + <refentry id="function.xpath-eval-expression"> <refnamediv> - <refname>domxml_version</refname> + <refname>xpath_eval_expression</refname> <refpurpose> - Get XML library version + Evaluates the XPath Location Path in the given string </refpurpose> </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>string</type><methodname>domxml_version</methodname> - <void/> - </methodsynopsis> + <methodsynopsis> + <type>array</type><methodname>xpath_eval_expression</methodname> + +<methodparam><type>object</type><parameter>xpath_context</parameter></methodparam> + </methodsynopsis> + &warn.experimental.func; <para> - This function returns the version of the XML library version currently used. + </para> + <para> + See also <function>xpath_eval</function> </para> </refsect1> </refentry>