How would you parse this?

Discussion in 'PHP' started by GeorgeB., Oct 27, 2006.

  1. #1
    OK I have a php script that goes out and grabs data from an amazon xml feed.

    Easy enough..

    But I only want the first image it returns. Right now it returns up to 10.

    Here's an example of the data it returns:
    How would you grab just the first image?
     
    GeorgeB., Oct 27, 2006 IP
  2. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #2
    You can use xml functions or regex for doing that. Regex example:
    
    if (preg_match('/<image[^>]*><\/image>/si',$s,$m))
     echo $m[0];
    
    PHP:
    there $s contains your xml.
     
    wmtips, Oct 27, 2006 IP