Removing schema details from ouput xml and converting into array (Using PHP SoapClient and simplexml_load_string or SimpleXMLElement) <p>I am getting XML response from third party service,</p> <pre><code>$soap = new SoapClient($wsdl, $options); $data = $soap-&gt;method($params); </code></pre> <p>Response looks like Stdclass object values</p> <p><strong>$data</strong> contains the xml inside the array object</p> <p><strong>$data->resultResponse->any</strong> contains below xml format,</p> <pre><code>&lt;xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet"&gt;&lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Temp" ..... &lt;/xs:element&gt;&lt;/xs:schema&gt;&lt;diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"&gt;&lt;DocumentElement xmlns=""&gt;&lt;Temp diffgr:id="Temp1" msdata:rowOrder="0"&gt;&lt;name&gt;Siva&lt;/name&gt;&lt;age&gt;18&lt;/age&gt;....&lt;location&gt;chennai&lt;/chennai&gt;&lt;/Temp&gt;&lt;Temp diffgr:id="Temp2" msdata:rowOrder="0"&gt;&lt;name&gt;John&lt;/name&gt;&lt;age&gt;18&lt;/age&gt;....&lt;location&gt;chennai&lt;/chennai&gt;&lt;/Temp&gt; </code></pre> <p></p> <p>I am getting below error When this xml using in to <strong>SimpleXMLElement</strong> or <strong>simplexml_load_string</strong> for array conversion ,</p> <pre><code>$res = $data-&gt;resultResponse-&gt;any; $res1 = new SimpleXMLElement($res); $res2 = simplexml_load_string($res); </code></pre> <p>For the both $res1 &amp; $res2,</p> <pre><code>Warning: simplexml_load_string(): Entity: line 1: parser error : Extra content at the end of the document in soap.php on line 40 </code></pre> <p>I don't want the <code>"&lt;xs:schema"</code> from that xml. I want <code>"&lt;diffgr:diffgram"</code> values.</p> <p>Previously, I used nusoap library for this. That is working fine for less memory data. Nusoap converts the whole xml into array. But, Php-Soap client gives only the first-level elements as objects/key.</p> <p>I tried already some ways in loadXml in DOM and preg_replace. But those are not much helpfull</p> <p>Please help me to resolve the problem.</p> <p><strong>Original xml response getting from Boomerang,</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;soap:Body&gt; &lt;ClaimMISResponse xmlns="http://tempuri.org/"&gt; &lt;ClaimMISResult&gt; &lt;xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt; &lt;xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Temp" msdata:UseCurrentLocale="true"&gt; &lt;xs:complexType&gt; &lt;xs:choice minOccurs="0" maxOccurs="unbounded"&gt; &lt;xs:element name="Temp"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="name" type="xs:string" minOccurs="0" /&gt; ... &lt;xs:element name="location" type="xs:string" minOccurs="0" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:choice&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; &lt;diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"&gt; &lt;DocumentElement xmlns=""&gt; &lt;Temp diffgr:id="Temp1" msdata:rowOrder="0"&gt; &lt;name&gt;John&lt;/name&gt; ... &lt;location&gt;Chennai&lt;/location&gt; &lt;/Temp&gt; &lt;/DocumentElement&gt; &lt;/diffgr:diffgram&gt; &lt;/ClaimMISResult&gt; &lt;/ClaimMISResponse&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre>