PrestaShop:从网络服务获取类别名称

PrestaShop: Get category name from webservice

我正在尝试从 PrestaShop API 获取类别名称。 但是我无法解析这个 xml 对象。我想获取值"Root",但我不知道如何实现。从 PrestaShop 数据中,我可以得到这个数据,我怎样才能得到 "Root" 值?

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();