Helle 那里,有一个帖子:https ://stackoverflow.com/questions/5816786/counting-nodes-in-a-xml-file-using-php 我有同样的问题,但不是计数,我想回应它。我在xml中有这段代码:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Row>
<ModeNumber>1</ModeNumber>
<Mode>online</Mode>
</Row>
<Row>
<ModeNumber>2</ModeNumber>
<Mode>mmorpg</Mode>
</Row>
这是PHP:
$xml = simplexml_load_file("include/gamemodes.xml");
foreach ($xml->Row->children() as $child)
{
echo $child->getName(), ": ", $child, "<br>";
}
它只回显第一行,仅此而已,我怎样才能让它回显多行,结果应该是:
ModeNumber: 1
Mode: online
ModeNumber: 2
Mode: mmorpg
对不起,我的英语不好。