PrestaShop:从webservice获取类别名称


PrestaShop: Get category name from webservice

我试图从PrestaShop API获得类别名称。但是我无法解析这个xml对象。我想得到值"根",但我不知道如何实现这一点。从PrestaShop数据,我可以得到这个数据,我怎么能得到"根"值?

object(SimpleXMLElement)#5 (2) { ["@attributes"]=> array(1) { ["id"]=> string(1) "2" } [0]=> string(4) "Root" }

这是我的代码:

$store_path = 'http://xxxx.com/';
$auth_key = 'xxxxxx';
$webService = new PrestaShopWebservice($store_path, $auth_key, false);
// The key-value array
$opt['resource'] = 'categories';
$opt['display'] = 'full';
$opt['limit'] = 10;
//Retrieving the XML data
$xml = $webService->get($opt);
var_dump($xml[0]->categories[0]->category->name->language[0][0]);

试试这个:

$resource = $xml->categories->children();
echo $resource->category->name->language[0]->__toString();