你好,我将过滤 xml 元素并显示一个具有指定标识的元素,如下所示:
<?php
$url11= 'http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v0002/?key=XXXXXXXXXXXXXXXXXX&appid=240&l=german&format=xml';
$data11 = file_get_contents($url11);
$xml = simplexml_load_string($data11);
$joke ="WIN_BOMB_PLANT";
foreach($xml->availableGameStats->achievements->achievement as $key => $value) {
if($value->name->__toString() != $joke) {
?>
<img src="<?php echo $value->icon->__toString(); ?>" border="0" height="64" width="64" >
<?php
}
}
?>
这是xml文档:
-<game>
<gameName>ValveTestApp260</gameName>
<gameVersion>181</gameVersion>
-<availableGameStats>
-<achievements>
-<achievement>
<name>WIN_BOMB_PLANT</name>
<displayName>Bombenleger</displayName>
<icon>
http://media.steampowered.com/steamcommunity/public/images/apps/240
/4711014791e4ae29408e8bc2fcae1ab61ca7c189.jpg
</icon>
</achievement>
-<achievement>
<name>BOMB_PLANT_LOW</name>
<displayName>Boomala Boomala</displayName>
<icon>
http://media.steampowered.com/steamcommunity/public/images/apps/240
/5f689c20656716f2a8bf67bd26f3f7846786bca5.jpg
</icon>
</achievement>
<achievement>
-Another things-
</achievement>
</achievements>
</availableGameStats>
</game>
但现在它显示了每一个元素。像这个例子:http: //i.stack.imgur.com/BagDu.jpg
但我希望脚本只显示这个指定的脚本,如下所示:http: //i.stack.imgur.com/X2Oph.png
任何人都可以帮助我吗?提前谢谢.. srry 我的英语不好或英语不好...