Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 5770

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get a SimpleXMLElement object from a DOM node.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.simplexml.html">SimpleXML Functions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.simplexml-load-file.html">simplexml_load_file</a></div>
 <div class="up"><a href="ref.simplexml.html">SimpleXML Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.simplexml-import-dom" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">simplexml_import_dom</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">simplexml_import_dom</span> &mdash; <span class="dc-title">Get a <em>SimpleXMLElement</em> object from a DOM node.</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.simplexml-import-dom-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.simplexmlelement.html" class="type SimpleXMLElement">SimpleXMLElement</a></span> <span class="methodname"><strong>simplexml_import_dom</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span> <code class="parameter">$node</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$class_name</code><span class="initializer"> = &quot;SimpleXMLElement&quot;</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   This function takes a node of a <a href="book.dom.html" class="link">DOM</a>
   document and makes it into a SimpleXML node. This new object can
   then be used as a native SimpleXML element. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.simplexml-import-dom-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">node</code></em></span>
     <dd>

      <p class="para">
       A <a href="book.dom.html" class="link">DOM</a> Element node
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">class_name</code></em></span>
     <dd>

      <p class="para">
       You may use this optional parameter so that
        <span class="function"><strong>simplexml_import_dom()</strong></span> will return an object of 
       the specified class. That class should extend the 
       <span class="type"><a href="class.simplexmlelement.html" class="type SimpleXMLElement">SimpleXMLElement</a></span> class.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.simplexml-import-dom-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a <span class="type"><a href="class.simplexmlelement.html" class="type SimpleXMLElement">SimpleXMLElement</a></span> or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.simplexml-import-dom-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-5520">
    <p><strong>Example #1 Importing DOM</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$dom&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$dom</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">loadXML</span><span style="color: #007700">(</span><span style="color: #DD0000">'&lt;books&gt;&lt;book&gt;&lt;title&gt;blah&lt;/title&gt;&lt;/book&gt;&lt;/books&gt;'</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$dom</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Error&nbsp;while&nbsp;parsing&nbsp;the&nbsp;document'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}<br /><br /></span><span style="color: #0000BB">$s&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">simplexml_import_dom</span><span style="color: #007700">(</span><span style="color: #0000BB">$dom</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$s</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">book</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">title</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
blah
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.simplexml-import-dom-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.dom-import-simplexml.html" class="function" rel="rdfs-seeAlso">dom_import_simplexml()</a> - Gets a DOMElement object from a
   SimpleXMLElement object</span></li>
    <li class="member"><a href="simplexml.examples-basic.html" class="xref">Basic SimpleXML usage</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ref.simplexml.html">SimpleXML Functions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.simplexml-load-file.html">simplexml_load_file</a></div>
 <div class="up"><a href="ref.simplexml.html">SimpleXML Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>