<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.5 $ --> <refentry id='function.dom-import-simplexml'> <refnamediv> <refname>dom_import_simplexml</refname> <refpurpose> Get a <classname>DOMElement</classname> object from a <classname>SimpleXMLElement</classname> object </refpurpose> </refnamediv> <refsect1> &reftitle.description; <methodsynopsis> <type>DOMElement</type><methodname>dom_import_simplexml</methodname> <methodparam><type>SimpleXMLElement</type><parameter>node</parameter></methodparam> </methodsynopsis> <para> This function takes the node <parameter>node</parameter> of class <link linkend="ref.simplexml">SimpleXML</link> and makes it into a <classname>DOMElement</classname> node. This new object can then be used as a native <classname>DOMElement</classname> node. If any errors occur, it returns &false;. </para> <example> <title>Import SimpleXML into DOM with <methodname>dom_import_simplexml</methodname></title> <programlisting role="php"> <![CDATA[ <?php $sxe = simplexml_load_string('<books><book><title>blah</title></book></books>'); if ($sxe === false) { echo 'Error while parsing the document'; exit; } $dom_sxe = dom_import_simplexml($sxe); if (!$dom_sxe) { echo 'Error while converting XML'; exit; } $dom = new domdocument("1.0"); $dom_sxe = $dom->importnode($dom_sxe, true); $dom_sxe = $dom->appendchild($dom_sxe); echo $dom->savexml(); ?> ]]> </programlisting> </example> <para> See also <function>simplexml_import_dom</function>. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->