From 6cb6357d10f6cbac5c6a6fd8f298d85d87433071 Mon Sep 17 00:00:00 2001 From: Mehdi Achour Date: Sun, 29 Aug 2004 18:54:42 +0000 Subject: [PATCH] added documentation and examples, fixed protos git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@167576 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../domxml/functions/DomAttribute-name.xml | 4 +- .../domxml/functions/DomAttribute-value.xml | 37 ++++++++++++- .../domxml/functions/DomDocument-add-root.xml | 10 ++-- .../functions/DomDocument-html-dump-mem.xml | 25 ++++++--- .../domxml/functions/DomDocument-xinclude.xml | 54 ++++++++++++++++++- .../domxml/functions/DomDocumentType-name.xml | 24 ++++++++- .../functions/DomDocumentType-system-id.xml | 12 +++-- .../DomElement-get-attribute-node.xml | 37 +++++++++++-- .../functions/DomElement-get-attribute.xml | 40 +++++++++++--- .../functions/DomElement-has-attribute.xml | 35 ++++++++++-- .../functions/DomElement-set-attribute.xml | 9 ++-- .../domxml/functions/DomElement-tagname.xml | 34 ++++++++++-- reference/domxml/functions/domxml-version.xml | 27 ++++++++-- 13 files changed, 301 insertions(+), 47 deletions(-) diff --git a/reference/domxml/functions/DomAttribute-name.xml b/reference/domxml/functions/DomAttribute-name.xml index 539dcac1fe..ef4fb386c9 100644 --- a/reference/domxml/functions/DomAttribute-name.xml +++ b/reference/domxml/functions/DomAttribute-name.xml @@ -1,5 +1,5 @@ - + @@ -18,7 +18,7 @@ This function returns the name of the attribute. - See also domattribute_value. + See also domattribute_value for an example. diff --git a/reference/domxml/functions/DomAttribute-value.xml b/reference/domxml/functions/DomAttribute-value.xml index 06856828d5..7b88f8b2d1 100644 --- a/reference/domxml/functions/DomAttribute-value.xml +++ b/reference/domxml/functions/DomAttribute-value.xml @@ -1,5 +1,5 @@ - + @@ -17,6 +17,41 @@ This function returns the value of the attribute. + + + Getting all the attributes of a node + +document_element(); +$attrs = $root->attributes(); + +echo 'Attributes of ' . $root->node_name() . "\n"; +foreach ($attrs as $attribute) { + echo ' - ' . $attribute->name . ' : ' . $attribute->value . "\n"; +} + +?> + +]]> + + &example.outputs; + + + + + See also domattribute_name. diff --git a/reference/domxml/functions/DomDocument-add-root.xml b/reference/domxml/functions/DomDocument-add-root.xml index ce756fd2d0..cbef39a2f0 100644 --- a/reference/domxml/functions/DomDocument-add-root.xml +++ b/reference/domxml/functions/DomDocument-add-root.xml @@ -1,5 +1,5 @@ - + @@ -11,7 +11,7 @@ Description - resourceDomDocument->add_root + objectDomDocument->add_root stringname &warn.experimental.func; @@ -26,9 +26,9 @@ add_root("HTML"); -$head = $root->new_child("HEAD", ""); -$head->new_child("TITLE", "Hier der Titel"); +$root = $doc->add_root("html"); +$head = $root->new_child("head", ""); +$head->new_child("title", "Hier der Titel"); echo htmlentities($doc->dump_mem()); ?> ]]> diff --git a/reference/domxml/functions/DomDocument-html-dump-mem.xml b/reference/domxml/functions/DomDocument-html-dump-mem.xml index 519a91d465..a7d6eaeab7 100644 --- a/reference/domxml/functions/DomDocument-html-dump-mem.xml +++ b/reference/domxml/functions/DomDocument-html-dump-mem.xml @@ -1,5 +1,5 @@ - + @@ -25,21 +25,32 @@ create_element("HTML"); + +$root = $doc->create_element("html"); $root = $doc->append_child($root); -$head = $doc->create_element("HEAD"); + +$head = $doc->create_element("head"); $head = $root->append_child($head); -$title = $doc->create_element("TITLE"); + +$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 "
";
-echo htmlentities($doc->html_dump_mem());
-echo "
"; + +echo $doc->html_dump_mem(); ?> ]]>
+ &example.outputs; + +This is the title +]]> + diff --git a/reference/domxml/functions/DomDocument-xinclude.xml b/reference/domxml/functions/DomDocument-xinclude.xml index 5678dd0450..d3fb5fa717 100644 --- a/reference/domxml/functions/DomDocument-xinclude.xml +++ b/reference/domxml/functions/DomDocument-xinclude.xml @@ -1,5 +1,5 @@ - + DomDocument->xinclude @@ -14,8 +14,58 @@ &warn.experimental.func; - &warn.undocumented.func; + + This function substitutes XIncludes in a DomDocument object. + + + + Substitu + +test + +$xml = ' + + + + xinclude: include.xml not found + + +'; + +$domxml = domxml_open_mem($xml); +$domxml->xinclude(); + +echo $domxml->dump_mem(); + +?> +]]> + + &example.outputs; + + + + test + +]]> + + + If include.xml doesn't exist, you'll see: + + + + + xinclude:dom.xml not found + +]]> + + +
diff --git a/reference/domxml/functions/DomDocumentType-name.xml b/reference/domxml/functions/DomDocumentType-name.xml index d960a4258b..d0a65f35a6 100644 --- a/reference/domxml/functions/DomDocumentType-name.xml +++ b/reference/domxml/functions/DomDocumentType-name.xml @@ -1,5 +1,5 @@ - + @@ -17,6 +17,28 @@ This function returns the name of the document type. + + + Getting the document type's name + +doctype(); +echo $doctype->name(); // chapter + +?> +]]> + + + diff --git a/reference/domxml/functions/DomDocumentType-system-id.xml b/reference/domxml/functions/DomDocumentType-system-id.xml index 576f0fa9e7..d6901f31b5 100644 --- a/reference/domxml/functions/DomDocumentType-system-id.xml +++ b/reference/domxml/functions/DomDocumentType-system-id.xml @@ -1,11 +1,11 @@ - + DomDocumentType->system_id - Returns system id of document type + Returns the system id of document type @@ -18,8 +18,6 @@ Returns the system id of the document type. - The following example echos - '/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd'. Retrieving the system id @@ -37,6 +35,12 @@ echo $doctype->system_id(); ?> ]]> + &example.outputs; + + + diff --git a/reference/domxml/functions/DomElement-get-attribute-node.xml b/reference/domxml/functions/DomElement-get-attribute-node.xml index 08f472d8e6..ebf6363e2b 100644 --- a/reference/domxml/functions/DomElement-get-attribute-node.xml +++ b/reference/domxml/functions/DomElement-get-attribute-node.xml @@ -1,21 +1,50 @@ - + DomElement->get_attribute_node - Returns value of attribute + Returns the node of the given attribute Description objectDomElement->get_attribute_node - objectattr + stringname - &warn.undocumented.func; + Returns the node of the attribute named name + in the current element. The name parameter is + case sensitive. + + + If no attribute with given name is found, &false; is returned. + + + + Getting an attribute node + +document_element(); +if ($attribute = $root->get_attribute_node('language')) { + echo 'Language is: ' . $attribute->value() . "\n"; +} + +?> +]]> + + diff --git a/reference/domxml/functions/DomElement-get-attribute.xml b/reference/domxml/functions/DomElement-get-attribute.xml index 9d92076d86..ab9b438059 100644 --- a/reference/domxml/functions/DomElement-get-attribute.xml +++ b/reference/domxml/functions/DomElement-get-attribute.xml @@ -1,26 +1,50 @@ - + DomElement->get_attribute - Returns value of attribute + Returns the value of the given attribute Description - objectDomElement->get_attribute + stringDomElement->get_attribute stringname - Returns the attribute with name name of the - current node. + Returns the value of the attribute named name + in the current node. The name parameter is case + sensitive. - - (PHP >= 4.3 only) If no attribute with given name is found, an empty - string is returned. + + Since PHP 4.3, if no attribute with given name is + found, an empty string is returned. + + + + Getting the value of an attribute + +document_element(); +echo $root->get_attribute('language')); // en + +?> +]]> + + See also domelement_set_attribute diff --git a/reference/domxml/functions/DomElement-has-attribute.xml b/reference/domxml/functions/DomElement-has-attribute.xml index a4748728d2..e0b77c4be5 100644 --- a/reference/domxml/functions/DomElement-has-attribute.xml +++ b/reference/domxml/functions/DomElement-has-attribute.xml @@ -1,11 +1,11 @@ - + DomElement->has_attribute - Checks to see if attribute exists + Checks to see if an attribute exists in the current node @@ -15,7 +15,36 @@ stringname - &warn.undocumented.func; + This functions checks to see if an attribute named + name exists in the current node. + + + + Testing the existence of an attribute + +document_element(); + +$buffer = 'has_attribute('language')) { + $buffer .= 'lang="' . $root->get_attribute('language') . '"'; +} +$buffer .= '>'; + +?> + +]]> + + diff --git a/reference/domxml/functions/DomElement-set-attribute.xml b/reference/domxml/functions/DomElement-set-attribute.xml index 9004eee8fa..b06b73ef1e 100644 --- a/reference/domxml/functions/DomElement-set-attribute.xml +++ b/reference/domxml/functions/DomElement-set-attribute.xml @@ -1,23 +1,24 @@ - + DomElement->set_attribute - Adds new attribute + Sets the value of an attribute Description - boolDomElement->set_attribute + objectDomElement->set_attribute stringname stringvalue Sets an attribute with name name to the given - value. If the attribute does not exist, it will be created. + value. If the attribute does not exist, it will + be created. diff --git a/reference/domxml/functions/DomElement-tagname.xml b/reference/domxml/functions/DomElement-tagname.xml index bc6a4b2fa9..e4103ec8a8 100644 --- a/reference/domxml/functions/DomElement-tagname.xml +++ b/reference/domxml/functions/DomElement-tagname.xml @@ -1,11 +1,11 @@ - + DomElement->tagname - Returns name of element + Returns the name of the current element @@ -15,7 +15,35 @@ - &warn.undocumented.func; + Returns the name of the current node. Calling this function is the same + as accessing the tagname property, or calling + DomElement->node_name of the current node. + + + + Getting the node name + +document_element(); +echo $root->tagname(); // chapter +echo $root->tagname; // chapter +echo $root->node_name(); // chapter + + +?> + +]]> + + diff --git a/reference/domxml/functions/domxml-version.xml b/reference/domxml/functions/domxml-version.xml index 4ad943fe59..de64f98371 100644 --- a/reference/domxml/functions/domxml-version.xml +++ b/reference/domxml/functions/domxml-version.xml @@ -1,11 +1,11 @@ - + domxml_version - Get XML library version + Gets the XML library version @@ -15,7 +15,28 @@ - This function returns the version of the XML library version currently used. + This function returns the version of the version of the XML library + currently used. + + + + <function>domxml_version</function> Example + + +]]> + + &example.outputs.similar; + + + +