我玩过json,但我只是从xml开始如何加载这个url然后解析gamertag?
网址是这样的:
http://xboxapi.xxxxxxx.co.uk/profile?apikey=$key&gamertag=$gamertag
然后返回
<xbox status="success" version="0.0.9">
<gamertag>l RaH l</gamertag>
<motto>I Win With Randoms</motto>
<avatar>
<full>http://avatar.xboxlive.com/avatar/l rah l/avatar-body.png</full>
<small>http://avatar.xboxlive.com/avatar/l rah l/avatarpic-s.png</small>
<large>http://avatar.xboxlive.com/avatar/l rah l/avatarpic-l.png</large>
</avatar>
<gamerscore>12550</gamerscore>
<biography><![CDATA[Bio]]></biography>
<recentactivity>
<game>
<title>Xbox.com</title>
<artwork>/Content/Images/Presence/xboxcom.jpg</artwork>
<presence>Last played less than a minute ago</presence>
</game>
<game id="1297287259">
<title>Halo: Reach</title>
<artwork>http://tiles.xbox.com/consoleAssets/4D53085B/en-US/largeboxart.jpg</artwork>
<gamerscore>
<current>1205</current>
<outof>1400</outof>
</gamerscore>
</game>
<game id="1297287142">
<title>Halo 3</title>
<artwork>http://tiles.xbox.com/consoleAssets/4D5307E6/en-US/largeboxart.jpg</artwork>
<gamerscore>
<current>1750</current>
<outof>1750</outof>
</gamerscore>
</game>
</recentactivity>
<freshness>new</freshness>
</xbox>
答案 0 :(得分:2)
您需要阅读PHP内置的XML处理功能
SimpleXML是最简单的选择 http://php.net/manual/en/book.simplexml.php
或者您可以手动浏览DOMDocument
还要确保您的xml在顶部有一个有效的xml声明
<?xml version="1.0" encoding="utf-8"?>