2013-02-02 1 views
-2

은 XML 파일입니다 http://steamcommunity.com/profiles/76561198044834372/games?tab=all&xml=1읽기 스트림 XML 파일

내가 SimpleXML을 함께 할하려했으나 성공하지 못했다.

누군가 게임 제목을 읽을 수있는 코드를 제공 할 수 있습니까? 게임 -> game-> 이름이 목록에있는 각 게임의 : 예를 들어

,

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

나는 게임의 이름을합니다.

미리 감사드립니다.

+1

"누군가 게임 제목을 읽을 코드를 제공 할 수 있습니까?", 코드는 없지만 껌을 씹을 수 있습니다. 니가 원해? –

+0

XML 읽기 기능을 사용하는 것에 대해 설명 드리겠습니다. – user1701227

+0

[CRUD 노드와 xml 파일의 노드 값에 대한 간단한 프로그램]의 가능한 복제본 (http://stackoverflow.com/questions/4906073/a-simple-program-to-crud-node-and-node-values-of -xml-file) – Gordon

답변

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