Is this the most efficient way to retrieve these xml elements using php? It is not too long but the three nested loops seems a bit weighty and just doesn't feel right.
Thank you very much, Todd
// get the existing xml file
$url = '../../page_xml/index.xml';
$xml = simplexml_load_file($url); // == Root tag
// get the sliderImages node
foreach($xml->Page as $page){
foreach($page->sliderImages as $sliderImages){
foreach($sliderImages->sliderImage as $sliderImage){
echo "<strong>Title:</strong> ".$sliderImage."<br/>";
}
}
}
EDIT:
Here is the xml:
<?xml version="1.0" encoding="utf-8" ?>
<Root type="content">
<Page>
<hMenuHighlight>home</hMenuHighlight>
<pageName>Home</pageName>
<sliderImages>
<sliderImage>images/home_slider/paper_bag.jpg</sliderImage>
<sliderImage>images/home_slider/red_box.jpg</sliderImage>
<sliderImage>images/home_slider/cubes.jpg</sliderImage>
<sliderImage>images/home_slider/gift_boxes.jpg</sliderImage>
</sliderImages>
<pageText>
<![CDATA[
<h1>Welcome to myShopName</h1>
<!-- Start SLIDER IMAGES -->
<div id="slideshow">
<!--##mySlideshowImages-->
</div>
<!-- End SLIDER IMAGES -->
<p>Puzzle Logo image provided by <a href="http://www.logoease.com">Logoease</a>.</p>
<p>Paper bag image provided by <a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=1012">Felixco, Inc. / FreeDigitalPhotos.net</a>.</p>
<p>Red Box image provided by <a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=1058">Arvind Balaraman / FreeDigitalPhotos.net</a>.</p>
<p>Cubes image provided by <a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=1152">jscreationzs / FreeDigitalPhotos.net</a></p>
<p>Gift boxes image provided by <a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=1152">jscreationzs / FreeDigitalPhotos.net</a></p>
<p>Lorem ipsum dolor.</p>
]]>
</pageText>
</Page>
</Root>
XML? 3 nested loops seems bulky.