I have problem in code when i parse the XML to Array.it returns some tags and not the complete tags.I want to get all tags inside in soap response.I have xml file.and upload this file.
Here is data.txt file below:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="<a rel="nofollow" class="external free" href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>"
xmlns="urn:enterprise.soap.sforce.com">
<soapenv:Body>
<retrieveResponse>
<result xsi:type="sf:sObject">
<id>123</id>
<description>description</description>
<name>testing</imran>
<cnic>23198398213</cnic>
</result>
</retrieveResponse>
</soapenv:Body>
</soapenv:Envelope>
My PHP code:
<?php
ini_set("memory_limit", "44879M");
include("dom.php");
$xml = str_get_html( file_get_contents("data.txt") );
$final = array();
$result = $xml->find("result");
foreach($result as $r){
$tag = $r->children();
$one = array();
foreach($tag as $child){
$tag = $child->tag;
echo "<pre>";
print_r($tag); echo "<br>";
if( stristr($tag, ":") ){
list($com, $tag) = explode(":", $tag);
}
$one[$tag] = trim(strip_tags($child->innertext));
}
$final[] = $one;
//print_r($final); exit;
}
print_r($final);
?>
My output:
id
description
name
Array
(
[0] => Array
(
[id] => 123
[description] => description
[name] => testing 23198398213
)
)
My expected output should:
id
description
name
cnic
Array
(
[0] => Array
(
[id] => 123
[description] => description
[name] => testing
[cnic] => 23198398213
)
)
Please help
Thanks in Advance.