Can simplexmlelement maybe be used for this?
Yes it can and you already use it. However the problematic part is that you need to understand the XML structure first.
If you're debugging inside the browser the following is a quick help with simplexml:
$steamid = $_SESSION['steamid'];
$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=X&steamids=$steamid&format=xml";
$data = file_get_contents($url);
$xml = simplexml_load_string($data);
header('Content-Type: text/xml');
die($xml->asXML());
The first section is actually exactly your code, I just added two lines below that out the XML verbatim to the browser telling it that it is XML. Your browwer will then show the XML as is (often nicely formatted and you can open/close parts, have pretty printed and syntax highlighted with different colors, for example in Chromium).
You the can access the elements as outlined in the basic SimpleXML usage examples. You can not trust print_r
or var_dump
on SimpleXMLElements much because they don't show you the whole XML (sub) tree.