You are here:  » XML Search Feed


XML Search Feed

Submitted by multiz on Tue, 2006-09-12 22:14 in

Hello,
How would it be possible to stick an "XML" button at the bottom to search results pages on Price Tapestry? For example, could I stick the button on pages like: Search result for Atari: http://shop.multiz.com/search.php?q=atari.

Thanks in advance.
Michael
Video Games and Software Price Comparison Shop

Submitted by support on Wed, 2006-09-13 06:32

Hi Michael -

That's an interesting one! Certainly possible, but care would have to be taken regarding access etc. in terms of what load it would put on the database.

What application did you have in mind for the search feed?

Submitted by multiz on Wed, 2006-09-13 23:10

Yeah--you're probably right that it would take a huge strain on my system/server. But I do want a way to put the results on another site or subdomain.

For example, I have a multi search engine and I'd like to be able to put the price search results on my multi shopping page. How would that be possible?

Thanks for the reply.
Michael

Software & Video Games Price Comparison Shop

Submitted by support on Thu, 2006-09-14 09:01

Hi Michael,

You're doing that using the Google API etc.?

So what you want would be, for example, the option to add a parameter, say "format=xml" to the search query, e.g:

search.php?q=software&format=xml

...that would returns the results in an XML vocabulary that you are then going to parse and present on your multi-search page?

If that's what you want to do I think we should be able to knock something up in a few lines.... :)

Submitted by multiz on Fri, 2006-09-15 20:16

Thanks. Yeah that would be great.

Software & Video Games Price Comparison Shop

PS: I wrote Z.MultiZ.com to extract results from Google, Yahoo, and MSN using their API's (legally).

Submitted by support on Sun, 2006-09-17 02:57

Hi Michael,

Here's the code to generate an XML version of the search results. This section of code needs to go towards the end of search.php, just before the call to require("html/header.php"); as this is where the normal HTML output begins - so it is not necessary when generating XML.

  if ($_GET["format"] == "xml")
  {
    header("Content-Type: text/xml");
    print "<?xml version='1.0' encoding='UTF-8'?>";
    print "<products>";
    foreach($searchresults["products"] as $product)
    {
      print "<product>";
        print "<name><![CDATA[".$product["name"]."]]></name>";
        print "<description><![CDATA[".$product["description"]."]]></description>";
        print "<url><![CDATA[http://".$_SERVER["HTTP_HOST"].$config_baseHREF.$product["productHREF"]."]]></url>";
      print "</product>";
    }
    print "</products>";
    exit();
  }

To use this, simply append &format=xml to the end of any search URL. It generates an XML document using the familiar PRODUCTS/PRODUCT hierarchy, so if you're using Magic Parser in your multi search engine the Format String would be "xml|PRODUCTS/PRODUCT/".

Cheers,
David.