加载多个 XML(不同来源)并显示混合内容的方法是什么?
我的代码现在只加载一个 XML
<?php
$mobile = simplexml_load_file('mobile.xml');
$electronics = simplexml_load_file('electronics.xml');
foreach($mobile->product as $product)
{
echo '<div class="col-md-3">'."\n";
echo '<h4 class="img-responsive"><a href="'.$product->url.'">'.$product->name.'</a></h4>'."\n";
echo '<p><a href="'.$product->url.'"><img src="'.$product->image->large.'" class="img-responsive" /></a></p>'."\n";
echo '<p>'.$product->Price.'</p>'."\n";
echo '</div><!--end painting_record-->'."\n";
}
foreach($electronics->product as $product)
{
echo '<div class="col-md-3">'."\n";
echo '<h4 class="img-responsive"><a href="'.$product->url.'">'.$product->name.'</a></h4>'."\n";
echo '<p><a href="'.$product->url.'"><img src="'.$product->image->large.'" class="img-responsive" /></a></p>'."\n";
echo '<p>'.$product->Price.'</p>'."\n";
echo '</div><!--end painting_record-->'."\n";
}
?>
谢谢