这是XML文件: http://steamcommunity.com/profiles/76561198044834372/games?tab=all&xml=1
我尝试使用SimpleXML,但没有成功。
有人可以给我代码来阅读游戏标题吗?
例如,
<games>
<game>
<appID>570</appID>
<name>
<![CDATA[ Dota 2 ]]>
</name>
<logo>
<![CDATA[
http://media.steampowered.com/steamcommunity/public/images/apps/570/d4f836839254be08d8e9dd333ecc9a01782c26d2.jpg
]]>
</logo>
<storeLink>
<![CDATA[ http://steamcommunity.com/app/570 ]]>
</storeLink>
<hoursLast2Weeks>3.6</hoursLast2Weeks>
<hoursOnRecord>3.6</hoursOnRecord>
</game>
我想要游戏的名字: 游戏 - &GT;游戏 - &GT;名称 列表中的每个游戏。
提前致谢。
答案 0 :(得分:2)
无论如何,我认为你需要首先看到“如何提出问题”。
$xml = file_get_contents("http://steamcommunity.com/profiles/76561198044834372/games?tab=all&xml=1");
$xml = simplexml_load_string($xml);
foreach ($xml->games->game as $game) {
echo (string) $game->name;
}
输出;
Dota 2 Grand Theft Auto IV Champions Online: Free For All Company of Heroes Company of Heroes: Opposing Fronts Company of Heroes: Tales of Valor CrimeCraft GangWars Darksiders DC Universe Online Deus Ex: Human Revolution Global Agenda HOMEFRONT Demo Metro 2033 Red Faction: Armageddon Sniper: Ghost Warrior Team Fortress 2 The Lord of the Rings Online™ Tribes: Ascend