-2

Here is the XML file: http://steamcommunity.com/profiles/76561198044834372/games?tab=all&xml=1

I tried to do it with SimpleXML, but with no success.

Can someone give me the code to read the game title?

For example,

<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>

I want the name of the game: games->game->name of each game on the list.

Thanks in advance.

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93
user1701227
  • 23
  • 1
  • 4
  • 1
    "Can someone give me the code to read the game title?", We have no code, but chewing gum. You want? – Kerem Feb 02 '13 at 10:09
  • I would be happy to get the explanation of using an XML reading function. – user1701227 Feb 02 '13 at 10:11
  • possible duplicate of [A simple program to CRUD node and node values of xml file](http://stackoverflow.com/questions/4906073/a-simple-program-to-crud-node-and-node-values-of-xml-file) – Gordon Feb 02 '13 at 10:40

1 Answers1

2

I think you need to see first "how to ask a question", anyway.

$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;
}

Outputs;

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
Kerem
  • 11,377
  • 5
  • 59
  • 58