我试图从下面的肥皂响应中获取所有元素和值作为数组。但我只得到元素但没有价值。
我已经使用这个解析器来获取元素和值。提前致谢。
这是我正在使用的代码,
$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);
}