Results 1 to 6 of 6

Thread: AWS4 Parsing XML child elements ~ help

  1. #1
    Junior Registered
    Join Date
    Oct 2004
    Posts
    5

    Wink AWS4 Parsing XML child elements ~ help

    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:
    <ImageUrlSmall>

    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>

    AWS4 XML
    <SmallImage>
    <URL>
    <Height>
    <Width>

    <MediumImage>
    <URL>
    <Height>
    <Width>

    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..

  2. #2
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469
    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.

    Code:
      <?
    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">
    				  </a>
             <?php } // Show if recordset not empty ?>
     <? } ?>

  3. #3
    Junior Registered
    Join Date
    Oct 2004
    Posts
    5

    Still workin on it

    Thank you for the example, I'm still trying to figure out where to input on the page.

    Coffee + Too much programming all night =

  4. #4
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469
    need more help just ask

  5. #5
    Not that blue at all Blue Cat Buxton's Avatar
    Join Date
    May 2004
    Location
    UK
    Posts
    932
    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

  6. #6
    Junior Registered
    Join Date
    Oct 2004
    Posts
    5
    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

Similar Threads

  1. AWS4 / PHP ~ Images / Prices ???
    By shaunster in forum Advertising & Affiliate Programs
    Replies: 1
    Last Post: 10-09-2004, 11:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •