这是我的地址.xml
<?xml version="1.0" ?>
<!--Sample XML document -->
<AddressBook>
<Addressentry>
<firstName>jack</firstName>
<lastName>S</lastName>
<Address>2899,Ray Road</Address>
<Email>jkjsvsdka@ghu.edu</Email>
</Addressentry>
<Addressentry>
<firstName>Sid</firstName>
<lastName>K</lastName>
<Address>238,Baseline Road,TX</Address>
<Email>sk@ghu.edu</Email>
<Email>sk@gmail.com</Email>
</Addressentry>
<Addressentry>
<firstName>Satya</firstName>
<lastName>Yar</lastName>
<Address>6,Rural Road,Tempe,AZ</Address>
<Email>syarlag@ghu.edu</Email>
<Email>ssya@gmail.com</Email>
<Email>satag@yahoo.com</Email>
</Addressentry>
</AddressBook>
我正在尝试使用如下 PHP 代码加载所有条目。每个地址条目可以有一个或多个标签。现在从下面的代码中我只能提取一个标签。我的问题是如何提取与特定地址条目相关的所有标签。那就是我想在同一行打印所有电子邮件。
<?php
$theData = simplexml_load_File("address.xml");
foreach($theData->Addressentry as $theAddress) {
$theFirstName = $theAddress->firstName;
$theLastName = $theAddress->lastName;
$theAdd = $theAddress->Address;
echo "<p>".$theFirstName."
".$theLastName."<br/>
".$theAdd."<br/>
".$theAddress->Email."<br/>
</p>";
unset($theFirstName);
unset($theLastName);
unset($theAdd);
unset($theEmail);
}
?>
任何帮助,将不胜感激