I have an XML file that contains XML within it. How would I go about parsing everything into an array or object?
<DATA>
<ROW>
<id>1</id>
<message_id>123456789</message_id>
<brand_name>SAMPLE</brand_name>
<request_xml>
<?xml version="1.0" encoding="UTF-8"?>
<Email>
<Service>
<LogMessage/>
<Delivery>
<Synchronous/>
</Delivery>
</Service>
<Model>
<Head>
<From>[email protected] </From>
<To>[email protected]</To>
<Subject>Your Question</Subject>
</Head>
<ns2:ContactUs>
<ns2:Sender>
<ns2:FirstName>John</ns2:FirstName>
</ns2:Sender>
</ns2:ContactUs>
</Model>
<InlineImages/>
<History/>
</Email>
</request_xml>
<http_status>400</http_status>
<created_by>admin</created_by>
<created_on>2014-09-08 01:56:59</created_on>
</ROW>
</DATA>
My goal is to end up with somthing like that:
SimpleXMLElement Object
(
[ROW] => SimpleXMLElement Object
(
[id] => 1
[message_id] => 123456789
[brand_name] => SAMPLE
[request_xml] => SimpleXMLElement Object
(
...
[LogMessage] =>
...
[from] => [email protected]
...
)
[http_status] => 400
[created_by] => admin
[created_on] => 2014-09-08 01:56:59
)
)
I didn't put all levels of the request_xml in my example, but you get the idea. Basically I want that request_xml to be parsed like the rest of the XML file.
How could I achieve this? Thanks in advance for any help on this!
html_entity_decodeorstr_replacewith a specific set of entities.simplexml_load_string($xmlfile, 'SimpleXMLElement', LIBXML_NOENT);so I didn't need to usehtml_entity_decode.