1
調用的Prestashop web服務後,我收到響應,如下圖所示:如何從SimpleXMLElement對象檢索值
SimpleXMLElement Object
(
[order] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 1
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 2
)
)
)
)
我試圖通過循環以檢索內容,如下圖所示:
foreach($resources as $resource){
echo '<pre>';
print_r($resource['id']);
echo '</pre>';
}
這給了我:
SimpleXMLElement Object
(
[0] => 1
)
SimpleXMLElement Object
(
[0] => 2
)
如何檢索1和2這些對象的值?感謝
如果可以,更換爲DOM – ZiTAL
任何鏈接,我可以閱讀更多有關DOM更換呢? – Lomse
http://www.binarytides.com/php-tutorial-parsing-html-with-domdocument/ – ZiTAL