Search code examples
phpxmlsimplexmldecode

PHP XML Decode File


how can I get a list with the "steamID64" from that xml file via php?: http://steamcommunity.com/groups/BillKeyTrading/memberslistxml/?xml=1

Thats my current code:

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

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

        echo $steamid64;

    }

Solution

  • Loop over the ids, not the members. You only have 1 member.

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

    Alternatively loop inside your loop for each id:

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

    https://eval.in/699683