我需要解析以下XML响应:
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/"><SOAP:Body><m:LoginResponse xmlns:m="http://www.e-courier.com/schemas/" UserGUID="{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" UserID="1" LoginGUID=""/></SOAP:Body></SOAP:Envelope>
我需要获取UserGUID,因此我创建了以下代码:
$xmlResponse = $client->__doRequest($xml_request, $this->__url_request, "XML", SOAP_1_1);
$xml = simplexml_load_string($xmlResponse);
$xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
$xml->registerXPathNamespace('m', 'http://www.e-courier.com/schemas/');
foreach ($xml->xpath('//LoginResponse') as $a)
{
error_log(print_r($a));
}
问题是我从未在error_log上打印任何内容。 我做错了什么?
编辑:我发现$ xml没有成功创建...我应该在调用simplexml_load_string之前使用一些东西吗?