如何在PHP中解析SOAP响应

I have cracked my head the last few days trying to parse a soap response (via curl command-line), but I can not get it to work. I just want to get the object value of ResourceIdentifier which is rs-1304500829200-200. I am using PHP 5.3.x

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <ns2:deliverMDRecordsResponse xmlns:ns2="http://mdstore.data.dnetlib.eu/" xmlns:ns3="http://www.w3.org/2005/08/addressing">
      <return>
        <ns3:Address>http://129.70.12.20:8282/dnet-mdstore/services/MDStoreResultSet</ns3:Address>
        <ns3:ReferenceParameters>
           <ResourceIdentifier:ResourceIdentifier xmlns:ResourceIdentifier="http://www.driver.org" xmlns:wsa="http://www.w3.org/2005/08/addressing">rs-1304500829200-200</ResourceIdentifier:ResourceIdentifier>
       </ns3:ReferenceParameters>
        </return>
     </ns2:deliverMDRecordsResponse>
   </soap:Body>
 </soap:Envelope>

<?
 $response=<<<END ....soap response here... END; 

 $xml = simplexml_load_string($source);
 $xml->registerXPathNamespace('t', 'http://www.driver.org'); 
 foreach ($xml->xpath('//t:ResourceIdentifier') as $item)    
 { //  print_r($item);       
     echo $item->asXML();    
 }    
?>

You should really be using the built in SoapClient class if you can, or if you can't, use the PEAR SOAP libraries. As you're running PHP 5.3, SoapClient ought to be available.

On the issue of your use of Xpath, you're querying against the wrong namespace and element. The namespace of the element you're querying is "http://www.driver.org", thus this should work, though keep in mind that I haven't actually ran it, though it should be correct:

<?php
$xml = simplexml_load_string($response); 
$xml->registerXPathNamespace('rid', 'http://www.driver.org');
foreach ($xml->xpath('//rid:ResourceIdentifier') as $item) {
    echo (string) $item; 
}
?>

But please don't do that, use one of the two SOAP clients I mentioned. I've no idea where you got {http://apilistener.envoyservices.com}payment from as it's not mentioned in the response.