cvs: phpdoc /en/reference/dom/domdocument registernodeclass.xml
| From: | Hannes Magnusson | Date: | Tue, 28 Oct 2008 09:10:11 +0000 |
| Subject: | cvs: phpdoc /en/reference/dom/domdocument registernodeclass.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-2315@lists.php.net to get a copy of this message | ||
bjori Tue Oct 28 09:10:11 2008 UTC
Modified files:
/phpdoc/en/reference/dom/domdocument registernodeclass.xml
Log:
Improve example
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/dom/domdocument/registernodeclass.xml?r1=1.3&r2=1.4&diff_format=u
Index: phpdoc/en/reference/dom/domdocument/registernodeclass.xml
diff -u phpdoc/en/reference/dom/domdocument/registernodeclass.xml:1.3
phpdoc/en/reference/dom/domdocument/registernodeclass.xml:1.4
--- phpdoc/en/reference/dom/domdocument/registernodeclass.xml:1.3 Sun Dec 16 13:18:07 2007
+++ phpdoc/en/reference/dom/domdocument/registernodeclass.xml Tue Oct 28 09:10:11 2008
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<refentry xml:id="domdocument.registernodeclass" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>DOMDocument::registerNodeClass</refname>
@@ -138,6 +138,40 @@
</screen>
</example>
</para>
+ <para>
+ <example>
+ <title>Retrieving elements as custom class</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+class myElement extends DOMElement {
+ public function __toString() {
+ return $this->nodeValue;
+ }
+}
+
+$doc = new DOMDocument;
+$doc->loadXML("<root><element><child>text in
child</child></element></root>");
+$doc->registerNodeClass("DOMElement", "myElement");
+
+$element = $doc->getElementsByTagName("child")->item(0);
+var_dump(get_class($element));
+
+// And take advantage of the __toString method..
+echo $element;
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen role="xml">
+<![CDATA[
+string(9) "myElement"
+text in child
+]]>
+ </screen>
+ </example>
+
+ </para>
</refsect1>
</refentry>