|
11 | 11 | <refsect1 role="description">
|
12 | 12 | &reftitle.description;
|
13 | 13 | <methodsynopsis>
|
14 |
| - <type>DOMElement</type><methodname>dom_import_simplexml</methodname> |
| 14 | + <type class="union"><type>DOMAttr</type><type>DOMElement</type></type><methodname>dom_import_simplexml</methodname> |
15 | 15 | <methodparam><type>object</type><parameter>node</parameter></methodparam>
|
16 | 16 | </methodsynopsis>
|
17 | 17 | <para>
|
18 |
| - This function takes the node <parameter>node</parameter> of class |
19 |
| - <link linkend="ref.simplexml">SimpleXML</link> and makes it into a |
20 |
| - <classname>DOMElement</classname> node. This new object can then be used |
21 |
| - as a native <classname>DOMElement</classname> node. |
| 18 | + This function takes the given attribute or element <parameter>node</parameter> (a |
| 19 | + <classname>SimpleXMLElement</classname> instance) and creates a |
| 20 | + <classname>DOMAttr</classname> or <classname>DOMElement</classname> node, repectively. |
| 21 | + The new <classname>DOMNode</classname> refers to the same underlying XML node |
| 22 | + as the <classname>SimpleXMLElement</classname>. |
22 | 23 | </para>
|
23 | 24 | </refsect1>
|
24 | 25 | <refsect1 role="parameters">
|
|
29 | 30 | <term><parameter>node</parameter></term>
|
30 | 31 | <listitem>
|
31 | 32 | <para>
|
32 |
| - The <classname>SimpleXMLElement</classname> node. |
| 33 | + The attribute or element node to import (a <classname>SimpleXMLElement</classname> instance). |
33 | 34 | </para>
|
34 | 35 | </listitem>
|
35 | 36 | </varlistentry>
|
|
39 | 40 | <refsect1 role="returnvalues">
|
40 | 41 | &reftitle.returnvalues;
|
41 | 42 | <para>
|
42 |
| - The <classname>DOMElement</classname> node added. |
| 43 | + The <classname>DOMAttr</classname> or <classname>DOMElement</classname>. |
43 | 44 | </para>
|
44 | 45 | </refsect1>
|
45 | 46 |
|
@@ -95,6 +96,38 @@ echo $dom->saveXML();
|
95 | 96 | ?>
|
96 | 97 | ]]>
|
97 | 98 | </programlisting>
|
| 99 | + &example.outputs; |
| 100 | + <screen> |
| 101 | +<![CDATA[ |
| 102 | +<?xml version="1.0"?> |
| 103 | +<books><book><title>blah</title></book></books> |
| 104 | +]]> |
| 105 | + </screen> |
| 106 | + </example> |
| 107 | + <example> |
| 108 | + <title>Import SimpleXML into DOM and modify SimpleXML through DOM</title> |
| 109 | + <simpara> |
| 110 | + Error handling omitted for brevity. |
| 111 | + </simpara> |
| 112 | + <programlisting role="php"> |
| 113 | +<![CDATA[ |
| 114 | +<?php |
| 115 | +
|
| 116 | +$sxe = simplexml_load_string('<books><book><title>blah</title></book></books>'); |
| 117 | +$elt = dom_import_simplexml($sxe); |
| 118 | +$elt->setAttribute("foo", "bar"); |
| 119 | +echo $sxe->asXML(); |
| 120 | +
|
| 121 | +?> |
| 122 | +]]> |
| 123 | + </programlisting> |
| 124 | + &example.outputs; |
| 125 | + <screen> |
| 126 | +<![CDATA[ |
| 127 | +<?xml version="1.0"?> |
| 128 | +<books foo="bar"><book><title>blah</title></book></books> |
| 129 | +]]> |
| 130 | + </screen> |
98 | 131 | </example>
|
99 | 132 | </refsect1>
|
100 | 133 | <refsect1 role="seealso">
|
|
0 commit comments