0
我越來越低於SOAP API響應並試圖讀取XML節點值,但未獲取resultcode
& message
值。PHP - 無法讀取XML節點值
$result = '<?xml version="1.0" encoding="UTF-8"?>
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soap:body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tic:reservationresponse xmlns:tic="http://example.com/">
<tic:reservationresp>
<tic:resultcode>-204</tic:resultcode>
<tic:message>Invalid Location Id</tic:message>
</tic:reservationresp>
</tic:reservationresponse>
</soap:body>
</soapenv:envelope>';
$xml = simplexml_load_string($result);
$soapenv = $xml->children("http://schemas.xmlsoap.org/soap/envelope/");
$tns = $soapenv->Body->children("http://example.com/");
echo $tns->reservationresponse->reservationresp->resultcode;
我做錯了什麼。任何想法。
謝謝。