I am getting XML response from third party service,
$soap = new SoapClient($wsdl, $options);
$data = $soap->method($params);
Response looks like Stdclass object values
$data contains the xml inside the array object
$data->resultResponse->any contains below xml format,
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Temp" ..... </xs:element></xs:schema><diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><DocumentElement xmlns=""><Temp diffgr:id="Temp1" msdata:rowOrder="0"><name>Siva</name><age>18</age>....<location>chennai</chennai></Temp><Temp diffgr:id="Temp2" msdata:rowOrder="0"><name>John</name><age>18</age>....<location>chennai</chennai></Temp>
I am getting below error When this xml using in to SimpleXMLElement or simplexml_load_string for array conversion ,
$res = $data->resultResponse->any;
$res1 = new SimpleXMLElement($res);
$res2 = simplexml_load_string($res);
For the both $res1 & $res2,
Warning: simplexml_load_string(): Entity: line 1: parser error : Extra content at the end of the document in soap.php on line 40
I don't want the "<xs:schema" from that xml. I want "<diffgr:diffgram" values.
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.
I tried already some ways in loadXml in DOM and preg_replace. But those are not much helpfull
Please help me to resolve the problem.
Original xml response getting from Boomerang,
<?xml version="1.0" encoding="utf-8"?>
<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">
<soap:Body>
<ClaimMISResponse xmlns="http://tempuri.org/">
<ClaimMISResult>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Temp" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Temp">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0" />
...
<xs:element name="location" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<DocumentElement xmlns="">
<Temp diffgr:id="Temp1" msdata:rowOrder="0">
<name>John</name>
...
<location>Chennai</location>
</Temp>
</DocumentElement>
</diffgr:diffgram>
</ClaimMISResult>
</ClaimMISResponse>
</soap:Body>
</soap:Envelope>
DOMDocumentFragment::appendXml().