Parsing ebay xml file

Discussion in 'XML & RSS' started by Luke Jones, Aug 26, 2007.

  1. #1
    Hello,
    I'm trying to parse the following ebay xml file:
    <?xml version="1.0" encoding="utf-8" ?> 
    - <eBay>
      <EBayTime>2007-08-26 15:30:45</EBayTime> 
    - <Search>
    - <Items>
    - <Item>
      <Id>250156484175</Id> 
    - <Title>
    - <![CDATA[ Acura : CL 2001 ACURA  : CL 3.2
      ]]> 
      </Title>
    - <SubtitleText>
    - <![CDATA[ 
      ]]> 
      </SubtitleText>
      <CurrencyId>1</CurrencyId> 
      <Country>1</Country> 
    - <PostalCode>
    - <![CDATA[ 08724
      ]]> 
      </PostalCode>
    - <Link>
    - <![CDATA[ http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=250156484175&category=5332
      ]]> 
      </Link>
      <CurrentPrice>6500.00</CurrentPrice> 
      <LocalizedCurrentPrice>$6,500.00</LocalizedCurrentPrice> 
      <BINPrice>$9,590.00</BINPrice> 
      <BidCount>0</BidCount> 
      <FeedbackScore /> 
      <FeedbackPercent /> 
      <StartTime>2007-08-22 02:11:34</StartTime> 
      <EndTime>2007-08-27 00:03:50</EndTime> 
      <BillPointRegistered>0</BillPointRegistered> 
    - <ItemProperties>
      <BoldTitle>0</BoldTitle> 
      <Featured>0</Featured> 
      <Gallery>1</Gallery> 
      <GalleryFeatured>0</GalleryFeatured> 
    - <GalleryURL>
    - <![CDATA[ 
    http://thumbs.ebay.com/pict/250156484175.jpg
    						
    
      ]]> 
      </GalleryURL>
      <Picture>1</Picture> 
      <Highlight>0</Highlight> 
      <Border>0</Border> 
      <New>0</New> 
      <BuyItNow>1</BuyItNow> 
      <IsFixedPrice>0</IsFixedPrice> 
      <Type>1</Type> 
      <Gift>0</Gift> 
      <CharityListing>0</CharityListing> 
      <MotorsGermanySearchable>0</MotorsGermanySearchable> 
      </ItemProperties>
    - <ShippingDetail>
      <ShippingType>0</ShippingType> 
      </ShippingDetail>
      </Item>
    
    Code (markup):
    I'm using the following php code to parse it:

    if ($xml->Search->Items) {
    $contentcenter.="<h1>Auctions for " . str_replace("-"," ",ucwords($theproduct)) . " - <i>Click To Buy!</i></h1>";
    
    	$results = '';
    
    	// If the XML response was loaded, parse it and build links 
    	foreach ($xml->Search->Items as $categorysearch) {
    		$link  = $categorysearch->Item->Link . "&pid=$pid&aid=$aid";
    		$title = $categorysearch->Item->Title;
            $pic=$categorysearch->Item->ItemProperties->GalleryURL;
    		// For each SearchResultItem node, build a link and append it to $results
    		$results .="<div style=\"margin-bottom:20px;border:1px dotted #25829A;\">";
    
    		if (empty($pic)) {
    		$results .="\n<img src=\"pic.jpg\" alt=\"\" style=\"float:left;width:170px;margin-right:10px;\" />";
    		}else{
    		$results .="\n<img src=\"$pic\" alt=\"\" style=\"float:left;width:170px;height:120px;margin-right:10px;\" />";
    		}
    		
    		$results .= "<a href=\"http://rover.ebay.com/rover/1/711-1751-2978-331/1?AID=10370388&PID=2145562&mpre=" .urlencode($link). "\">$title</a>";
    		// For each SearchResultItem node, build a link and append it to $results
    		$results .= "<div style=\"clear:both\"></div></div>";
    
    	}
    }
    
    Code (markup):
    It's not working.
    Can anyone tell me what's wrong?

    Thanks,

    Luke
     
    Luke Jones, Aug 26, 2007 IP
  2. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ok, I've done it.
    Please ignore thread.
     
    Luke Jones, Aug 26, 2007 IP
  3. inhook

    inhook Well-Known Member

    Messages:
    248
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #3
    what was the problem
     
    inhook, Aug 31, 2007 IP