PHP XML 解码文件

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

如何通过 php 从该 xml 文件中获取包含“steamID64”的列表?: http://steamcommunity.com/groups/BillKeyTrading/memberslistxml/?xml=1

这是我当前的代码:

$file = simplexml_load_file('http://steamcommunity.com/groups/BillKeyTrading/memberslistxml/?xml=1
');

    foreach ($file->members as $steam){
        $steamid64=$steam->steamID64;

        echo $steamid64;

    }
php xml simplexml decode
1个回答
1
投票

循环遍历

id
,而不是
member
。您只有 1 名成员。

foreach ($file->members->steamID64 as $steam){
        echo $steam . "\n";
}

或者在循环中为每个 id 循环:

foreach ($file->members as $steam){
        foreach($steam->steamID64 as $steamid64) {
             echo $steamid64 . "\n";
        }
}

https://eval.in/699683

© www.soinside.com 2019 - 2024. All rights reserved.