kennyt          Wed Jan 28 20:23:00 2004 EDT

  Modified files:              
    /phpdoc/en/reference/simplexml      reference.xml 
    /phpdoc/en/reference/simplexml/functions    simplexml-load-dom.xml 
  Log:
  Added DOM examples.
  
  
http://cvs.php.net/diff.php/phpdoc/en/reference/simplexml/reference.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/simplexml/reference.xml
diff -u phpdoc/en/reference/simplexml/reference.xml:1.2 
phpdoc/en/reference/simplexml/reference.xml:1.3
--- phpdoc/en/reference/simplexml/reference.xml:1.2     Sat Jan 24 14:20:35 2004
+++ phpdoc/en/reference/simplexml/reference.xml Wed Jan 28 20:22:59 2004
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
  <reference id="ref.simplexml">
   <title>SimpleXML functions</title>
   <titleabbrev>SimpleXML</titleabbrev>
@@ -192,6 +192,38 @@
       </simpara>
      </example>
     </para>
+    <para>
+     <example>
+      <title>DOM Interoperability</title>
+      <simpara>
+       PHP has a mechanism to convert XML nodes between SimpleXML
+       and DOM formats. This example shows how one might change
+       a DOM element to SimpleXML.
+      </simpara>
+      <note>
+       <simpara>
+        This will only work with DOM in PHP 5, but SimpleXML wasn't
+        available before that version, so you should be fine.
+       </simpara>
+      </note>
+      <programlisting role="php">
+<![CDATA[
+<?php
+$dom = new domDocument;
+$dom->loadXML('<books><book><title>blah</title></book></books>');
+if(!$dom) {
+     echo 'Error while parsing the document';
+         exit;
+}
+
+$s = simplexml_import_dom($dom);
+
+echo $s->book[0]->title;
+?>
+]]>
+      </programlisting>
+     </example>
+    </para>
    </section>
   </partintro>
 
http://cvs.php.net/diff.php/phpdoc/en/reference/simplexml/functions/simplexml-load-dom.xml?r1=1.1&r2=1.2&ty=u
Index: phpdoc/en/reference/simplexml/functions/simplexml-load-dom.xml
diff -u phpdoc/en/reference/simplexml/functions/simplexml-load-dom.xml:1.1 
phpdoc/en/reference/simplexml/functions/simplexml-load-dom.xml:1.2
--- phpdoc/en/reference/simplexml/functions/simplexml-load-dom.xml:1.1  Fri Jan 23 
11:17:17 2004
+++ phpdoc/en/reference/simplexml/functions/simplexml-load-dom.xml      Wed Jan 28 
20:23:00 2004
@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
   <refentry id='function.simplexml-load-dom'>
    <refnamediv>
     <refname>simplexml_load_dom</refname>
     <refpurpose>
-     <!-- ref.dom*xml* should really be ref.dom, but that's not written
-     yet, so linking to ref.domxml (kennyt) -->
      Get a <literal>simplexml_element</literal> object from a
      DOM node.
     </refpurpose>
@@ -24,7 +22,29 @@
      it returns &false;.
     </para>
     <!-- php5 DOM isn't documented; this depends on it... :| -->
-    &warn.undocumented.func;
+    <example>
+     <title>Import DOM</title>
+     <programlisting role="php">
+<![CDATA[
+<?php
+$dom = new domDocument;
+$dom->loadXML('<books><book><title>blah</title></book></books>');
+if(!$dom) {
+    echo 'Error while parsing the document';
+    exit;
+}
+
+$s = simplexml_import_dom($dom);
+
+echo $s->book[0]->title;
+?>
+]]>
+     </programlisting>
+     <simpara>
+      This code should output:
+     </simpara>
+     <screen>blah</screen>
+    </example>
    </refsect1>
   </refentry>
 

Reply via email to