0
XML代码(FileZilla中server.xml中)用foreach循环的第二个层次:PHP不会继续在XML
<FileZillaServer>
<Users>
<User Name="Bill">
<Option Name="Pass">window</Option>
</User>
<User Name="Paul">
<Option Name="Pass">apple</Option>
</User>
</Users>
</FileZillaServer>
PHP代码:
$filezilla = 'FileZilla Server.xml';
$xml = simplexml_load_file($filezilla);
foreach ($xml->Users->User as $user) {
echo "<strong>".$user['Name']."</strong><br />";
foreach ($xml->Users->User->Option as $option) {
if ($option['Name'] == "Pass") {
echo $option."<br />";
}
}
echo "<br />";
}
输出是:
Bill
window
Paul
window
输出应该是:
Bill
window
Paul
apple
看来,该内部的foreach重演没有进一步打算。 我该如何解决这个问题?
谢谢。
这工作了,非常感谢你! – PhilG