如何在键中使用@来检索SimpleXMLElement对象的值

问题描述 投票:0回答:1

我从eBay API返回了此信息。如何使用PHP访问count中的值?

(
    [ack] => Success
    [version] => 1.13.0
    [timestamp] => 2020-04-13T00:01:52.128Z
    [searchResult] => SimpleXMLElement Object
        (
            [@attributes] => Array
                (
                    [count] => 0
                )

        )
...

我尝试了以下操作,但无济于事

$x->searchResult->@attributes->count;

$x->searchResult['@attributes']->count;

php simplexml
1个回答
0
投票

查看所有属性使用

foreach ($xml->searchResult->attributes() as $a=>$b)
    echo "[$a] = $b <BR>";
© www.soinside.com 2019 - 2024. All rights reserved.