title: PHP parse XML within XML
body: <p>I have an XML file that contains XML within it. How would I go about parsing everything into an array or object?</p>
  
  <pre><code>&lt;DATA&gt;
      &lt;ROW&gt;
          &lt;id&gt;1&lt;/id&gt;
          &lt;message_id&gt;123456789&lt;/message_id&gt;
          &lt;brand_name&gt;SAMPLE&lt;/brand_name&gt;
          &lt;request_xml&gt;
  &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
  &amp;lt;Email&amp;gt;
  &amp;lt;Service&amp;gt;
  &amp;lt;LogMessage/&amp;gt;
  &amp;lt;Delivery&amp;gt;
  &amp;lt;Synchronous/&amp;gt;
  &amp;lt;/Delivery&amp;gt;
  &amp;lt;/Service&amp;gt;
  &amp;lt;Model&amp;gt;
  &amp;lt;Head&amp;gt;
  &amp;lt;From&amp;gt;someone@example.com &amp;lt;/From&amp;gt;
  &amp;lt;To&amp;gt;someone@sample.com&amp;lt;/To&amp;gt;
  &amp;lt;Subject&amp;gt;Your Question&amp;lt;/Subject&amp;gt;
  &amp;lt;/Head&amp;gt;
  &amp;lt;ns2:ContactUs&amp;gt;
  &amp;lt;ns2:Sender&amp;gt;
  &amp;lt;ns2:FirstName&amp;gt;John&amp;lt;/ns2:FirstName&amp;gt;
  &amp;lt;/ns2:Sender&amp;gt;
  &amp;lt;/ns2:ContactUs&amp;gt;
  &amp;lt;/Model&amp;gt;
  &amp;lt;InlineImages/&amp;gt;
  &amp;lt;History/&amp;gt;
  &amp;lt;/Email&amp;gt;
          &lt;/request_xml&gt;
          &lt;http_status&gt;400&lt;/http_status&gt;
          &lt;created_by&gt;admin&lt;/created_by&gt;
          &lt;created_on&gt;2014-09-08 01:56:59&lt;/created_on&gt;
      &lt;/ROW&gt;
  &lt;/DATA&gt;
  </code></pre>
  
  <p>My goal is to end up with somthing like that:</p>
  
  <pre><code>SimpleXMLElement Object
  (
      [ROW] =&gt; SimpleXMLElement Object
          (
              [id] =&gt; 1
              [message_id] =&gt; 123456789
              [brand_name] =&gt; SAMPLE
              [request_xml] =&gt; SimpleXMLElement Object
                  (
                      ...
                      [LogMessage] =&gt; 
                      ...
                      [from] =&gt; someone@example.com
                      ...
                  )
  
              [http_status] =&gt; 400
              [created_by] =&gt; admin
              [created_on] =&gt; 2014-09-08 01:56:59
          )
  )
  </code></pre>
  
  <p>I didn't put all levels of the <code>request_xml</code> in my example, but you get the idea. Basically I want that <code>request_xml</code> to be parsed like the rest of the XML file.</p>
  
  <p>How could I achieve this? Thanks in advance for any help on this!</p>