9
我在解析來自Google Checkout響應中的XML時遇到了一些問題。 XML直接來自於谷歌服務器,所以XML本身沒有問題。SimpleXmlElement和XPath,獲取空數組()
我想獲得的所有新進訂單通知標籤
我嘗試這樣的電話,但得到一個空數組()返回每次。
$xml = new SimpleXmlElement($raw_xml);
$notifications = $xml->xpath('notifications');
$notifications = $xml->xpath('/notification-history-response/notifications/new-order-notification');
$notifications = $xml->xpath('//new-order-notification');
的XML snipet(剛開始)
<notification-history-response xmlns="http://checkout.google.com/schema/2" serial-number="c5cda190-0eb1-4f91-87cd-e656e5598d38">
<notifications>
<new-order-notification serial-number="271578974677716-00001-7">
<buyer-billing-address>
<address1>19 sandbox st</address1>
<address2></address2>
* XML直接來自谷歌服務器,所以XML本身沒有問題。*是的,谷歌在這方面幾乎就像@Jon Skeet。根據定義,它們的XML格式良好。 ;-) – LarsH 2010-10-26 21:16:34