我正在使用Soap进行Web服务调用和PHP进行整个操作。当我发送请求时,我得到响应为“341025COMPLETE”。但是当我为Source选择它时,它会在它后面输出xml。
XMl是这样的:
"<testscreening xmlns="https://www.test.com/xml/services/PSI">
<response>
<reportID>341025</reportID>
<backgroundreport></backgroundreport>
<status>COMPLETE</status>
</response>
</testscreening>"
如果我想要我可以存储到数据库的输出我怎样才能实现它? 注意:此处提到的xmlns根据隐私进行更改。
答案 0 :(得分:1)
使用DOMDocument
:
$dom = new DOMDocument;
$dom->loadXML($xml);
$el = $dom->getElementsByTagName('*');
foreach($el as $one){
if($one->nodeName == 'reportID'){
$reportId = $one->nodeValue;
}
if($one->nodeName == 'status'){
$status = $one->nodeValue;
}
}
echo $reportId.' - '.$status;
// 341025 - COMPLETE