我有一个 XML 文件。它如下所示:
<Offers>
<Offer>
<OfferID>1</OfferID>
<OfferName>Offer One</OfferName>
</Offer>
<Offer>
<OfferID>2</OfferID>
<OfferName>Offer Two</OfferName>
</Offer>
</Offers>
我有一个声明如下的变量:
$latest_offers = simplexml_load_file("Offers.xml");
现在我的问题是我怎样才能得到这样的输出:
foreach($offer as $item)
{
echo <offerID>, <OfferName>...each and everything inside the offer nod
}
我怎样才能做到这一点。尝试了很多但没有成功。