Google SVG Search III (2/2) - exploring XML | WebReference

Google SVG Search III (2/2) - exploring XML

Google SVG Search III

The result page is as straight-forward, including the embed tag for the SVG with a properly generated URL to trigger the Perl script again to fill in the results:

    print <<EOF;
content-type: text/html
<html><head><title>Search Results</title></head>
<body><h1>Search Results</h1>
<embed src="?q=$query&p=svg" name="results" width="600" height="600"
type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/">
</embed></body></html>
EOF

Search Results


And last but not least we change the existing code for generating SVG to use standard output for feeding back the results instead of writing them to a file:

    my $googleSearch = SOAP::Lite->service('file:GoogleSearch.wsdl');
    my $key = '00000000000000000000000000000000';
    $ENV{HTTP_proxy} = 'http://proxy:3128'; # if necessary
    my $result = $googleSearch->doGoogleSearch($key, $query, 0, 10, 'false', '', 'false', '', 'latin1', 'latin1');
    
    my $i = 0;
    my $svg = new SVG;
    foreach my $e (@{$result->{'resultElements'}}) {
      svgelement($i, $svg, $e->{'summary'}, $e->{'title'}, $e->{'URL'}, $e->{'directoryCategory'}->{'fullViewableName'}, $e->{'directoryTitle'}, $e->{'snippet'});
      $i++;
    }
    print "content-type: image/svg+xml\n\n";
    print $svg->render();
  }

With these simple modifications we turned our stand-alone Perl script into a CGI. The CGI module comes with a stand-alone mode mainly used for debugging, where you can still call the script from the command line and manually supply parameters. Download the script (not including WebReference site specifics) or try it online to see for yourself!


Produced by Michael Claßen

URL: http://www.webreference.com/xml/column57/2.html
Created: Jun 10, 2002
Revised: Jun 10, 2002