我只想在 PHP foreach 循环中显示以下 XML 记录,
<?xml version="1.0" encoding="utf-8"?>
<Node>
<game_takes>
<game_take>
<id type="System.String">0</id>
<name type="System.String">take1</name>
</game_take>
<game_take>
<id type="System.String">1</id>
<name type="System.String">take2</name>
</game_take>
<game_take>
<id type="System.String">2</id>
<name type="System.String">take3</name>
</game_take>
<game_take>
<id type="System.String">3</id>
<name type="System.String">take4</name>
</game_take>
</game_takes>
</Node>
我一直在尝试的是
$grabme = simplexml_load_file('gamecast.xml');
foreach ($grabme->game_take as $key) {
echo $key['name'];
}
似乎没有什么工作,有人可以帮帮我吗?