View Full Version : AWS4 Parsing XML child elements ~ help

10-12-2004, 05:28 AM
Quick question: trying to migrate from AWS3 to AWS4 using Obrien's script. Everything is is more less coming together except one blasted problem...

How do you parse child elements from a root element in the XML?

Example AWS3 XML:

Example AWS3 PHP Parsing:
elseif($d_ar[$j]['tag'] == 'SmallImageUrl') {$SmallImageUrl = $d_ar[$j]['value'];}

then Display the image AWS3:
<a href="product.php4?ASIN=<?=$ASIN"<?=$ImageUrlSmall?>" style="float: left; margin-right: 20px;" border="0" alt="" /><URL></a>



Example AWS4 PHP Parsing:
// This is where I am Stuck;

elseif($d_ar[$j]['tag'] == 'SmallImage') {$SmallImage = $d_ar[$j]['value'];}
elseif($d_ar[$j]['tag'] == 'URL') {$URL = $d_ar[$j]['value'];}

then Display the image AWS4:
<a href="product.php4?ASIN=<?=$ASIN"<?=$URL?>" style="float: left; margin-right: 20px;" border="0" alt="" /><URL></a>

Obviously you can not populate Height & Width with an empty string (?), but I cannot seem to grasp how to get the Child elements from the root element. I am assuming this would be an array?

Would anyone be able to help me with an example..

10-12-2004, 06:22 AM
Its an array, here is an example cut and paste right from my site. It has a code check so that if the product doesnt have an image it skips it. You can ignore that bit.

foreach($zombie['Item'] as $r)
{ ?>
<div align="center">
<?php if ($r['MediumImage']['URL']['_value_'] != "") { // Show if recordset not empty ?>
<a href="dvd<? echo $r['ASIN']['_value_']; ?>.htm">
<img src="<? echo $r['MediumImage']['URL']['_value_']; ?>" alt="<? echo $r['ItemAttributes']['Title']['_value_']; ?>" width="80" border="0" align="left">
<?php } // Show if recordset not empty ?>
<? } ?>

10-12-2004, 07:37 AM
Thank you for the example, I'm still trying to figure out where to input on the page.

Coffee + Too much programming all night = :eek:

10-12-2004, 07:45 AM
need more help just ask :)

Blue Cat Buxton
10-12-2004, 08:27 AM
If it helps in placing it on the page, the OBrien script gets all the data from the xml file then spits it out whereas Emancipators code spits it straight out.

You may need to copy the results into a variable then put them out with all the other data

10-12-2004, 08:42 AM
Yep, I think I got lost. Going to start over with that page... One of those things I guess. I am so close I can taste it. I think I am missing something pretty obvious, I wish O'Brien had cool migration article ;)