I am trying to get all the elements and values as array from the below soap response. But I am only getting elements but no values.
I have used this parser to get the elements and values. Thanks in advance.
Here is the code I am using,
$response = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<toy:SearchReq xmlns:toy="www.something.com/toy" xmlns:gen="www.something.com/gen">
<gen: manufacturedIn="SomePlace"/>
<toy:SearchToy>
<toy:SearchType>
<gen:Shop Code="WALMART"/>
</toy:SearchType>
</toy:SearchToy>
<toy:SearchToy>
<toy:SearchType>
<gen:Shop Code="AMAZON"/>
</toy:SearchType>
</toy:SearchToy>
</toy:SearchReq>
</soapenv:Body>
</soapenv:Envelope>';
$doc = simplexml_load_string($response);
$path = array($doc
->children('http://schemas.xmlsoap.org/soap/envelope/')
->Body
->children('www.something.com/toy'));
foreach($path as $elem){
print_r($elem);
$elemChild = $elem->children('www.something.com/gen');
var_dump($elemChild);
}