title: Getting the XML content of a SimpleXMLElement
body: <p>Is there a way to extract the "innerHTML" of a SimpleXMLElement?</p>
  
  <p>For example how would I get <code>'&lt;div&gt;&lt;h1&gt;Hello World&lt;/h1&gt;&lt;/div&gt;'</code> out of the following XML Code using SimpleXMLElement:</p>
  
  <pre><code>&lt;xml&gt;
    &lt;body1&gt;
      &lt;div&gt;&lt;h1&gt;Hello World&lt;/h1&gt;&lt;/div&gt;
    &lt;/body1&gt;
    &lt;body2&gt;
      &lt;div&gt;&lt;h2&gt;Goodby Moon&lt;/h2&gt;&lt;/div&gt;
    &lt;/body2&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <hr>
  
  <p>I read the documentation and all I came up with was <code>$xml-&gt;body1-&gt;asXML();</code>.
  It is almost the right solution but it also adds the root tag:</p>
  
  <pre><code> &lt;body1&gt;
     &lt;div&gt;&lt;h1&gt;Hello World&lt;/h1&gt;&lt;/div&gt;
   &lt;/body1&gt;
  </code></pre>
  
  <p>Is it possible to skip the surrounding body1 tags?</p>
  
  <hr>
  
  <p>Edit:</p>
  
  <p>The xml might also look like this:</p>
  
  <pre><code>&lt;xml&gt;
    &lt;body1&gt;
      &lt;div&gt;&lt;h1&gt;Hello World&lt;/h1&gt;&lt;/div&gt;
      &lt;div&gt;&lt;h1&gt;Hello Moon&lt;/h1&gt;&lt;/div&gt;
      Some Text
    &lt;/body1&gt;
    &lt;body2&gt;
      &lt;div&gt;&lt;h2&gt;Goodby Moon&lt;/h2&gt;&lt;/div&gt;
    &lt;/body2&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p>As in: <a href="http://codepad.org/8ZuRYZOW" rel="noreferrer">http://codepad.org/8ZuRYZOW</a></p>