2016-07-26 6 views
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; 

私は間違っています。何か案が。

ありがとうございました。

答えて

0

あなたはおそらく自分を蹴るでしょうが、タグ名では大文字と小文字が区別されます。

$tns = $soapenv->body->children("http://example.com/"); 
:あなただけに

$tns = $soapenv->Body->children("http://example.com/"); 

を変更する必要があります