XML 是这样的:
<CRates>
<Date>20010323</Date>
<Currencies>
<Currency>
<ID>AED</ID>
<Units>1</Units>
<Rate>0.17200000</Rate>
</Currency>
<Currency>
<ID>ATS</ID>
<Units>1</Units>
<Rate>0.04102750</Rate>
</Currency>
</Currencies>
</CRates>
php是这样的:
$currencies = simplexml_load_file('__joomla.xml');
/**/
$cdate=$currency->Date;
echo "<time>". $date. "</time><br>";
foreach ($currencies as $currency):
$id=$currency->ID;
$units=$currency->Units;
$rate=$currency->Rate;
echo
"
<div class='id'>". $id. "</div>
<div class='units'>". $units. "</div>
<div class='rate'>". $rate. "</div>
";
endforeach;
如果删除<CRates> <Date>20010323</Date>
并删除结尾</CRates>
,一切正常。
但未删除,不显示任何内容。
请建议需要纠正的地方。