Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

parser.pm

0 views
Skip to first unread message

mira...@gmail.com

unread,
Sep 8, 2006, 11:21:25 AM9/8/06
to
I may have solved my earlier problem, however I have another now.
This is the error:

not well-formed at line 8, column 0, byte 532 at
c:/Perl/site/lib/XML/Parser.pm
line 168

So I opened parser.pm and went to line 168, it looks like this:

my $result = $expat->parse($arg);

Ok what do I do next, help please! :-)

Thanks


Tom

mira...@gmail.com

unread,
Sep 8, 2006, 11:38:40 AM9/8/06
to
Ok, I should have said when I get the error.
I get the error when I run a search query script with Perl.

.

Manfred

unread,
Sep 8, 2006, 12:04:14 PM9/8/06
to
mira...@gmail.com wrote:
> > This is the error:
> >
> > not well-formed at line 8, column 0, byte 532 at
> > c:/Perl/site/lib/XML/Parser.pm
> > line 168
What is the message returned from the api? Is the status
anything but 200 OK ? Can you see the http header info ?

The error occurs somewhere around line 8 in the document
returned (maybe soap or html).

Manfred

mira...@gmail.com

unread,
Sep 8, 2006, 12:20:56 PM9/8/06
to
I cant see anything, that is all that happens.
Doesn't seem to get to the api at this stage.

Manfred

unread,
Sep 8, 2006, 1:08:35 PM9/8/06
to
mira...@gmail.com wrote:
> I cant see anything, that is all that happens.

You have to make sure to be able to inspect the soap request
(after serialization) as it is sent to the api, and also be able to
inspect the response _before_ it gets parsed.
http://search.cpan.org/~kbrown/SOAP-0.28/lib/SOAP.pm#The_Parser_Object

> Doesn't seem to get to the api at this stage.

What do you think gets parsed if not the response ?

Manfred

mira...@gmail.com

unread,
Sep 10, 2006, 4:11:52 AM9/10/06
to
Thankyou for your reply and infomation re seialisation,
request/response etc, I have started looking into this.
I am rather new to Perl / scripting, I recently purchased a copy of
Google Hacks 3rd Edition. Typed up Hack 90.
My system is running windows.

Below is the code:

#!C:\perl\bin\perl.exe
# googly.pl
# A Google API Perl Script.
# Usage: perl googly.pl <query>

# Your Google API developer's key.
my $google_key='my google key here';

# Location of the GoogleSearch WSDL file.
my $google_wsdl = "GoogleSearch.wsdl";

use strict;

# Use the sOAP::Lite Perl module.
use SOAP::Lite;

# Take the query from the command line.
my $query = shift @ARGV or die "Usage: perl googly.pl <query>\n";

# Create a new SOAP::Lite instance, feeding it GoogleSearch.wsdl.
my $google_search = SOAP::Lite->service("file:$google_wsdl");

# Query Google
my $results = $google_search ->
doGoogleSearch(
$google_key, $query, 0, 10, "false", "", "false",
"", "latin1", "latin1"
);

# No results?
@{$results->{resultElements}} or exit;

# Loop through the results.
foreach my $result (@{$results->{resultElements}}) {
# Set the results as variables
my $title = $result->{title} || "no title";
my $url = $result->{url};
my $snippet = $result->{snippet} || 'no snippet';

# Strip HTML from the results
$title =~ s!<[^>]+>!!gis;
$snippet =~ s!<[^>]+>!!gis;

# Print out the main bits of each result
print
join "\n",
$title,
$url,
$snippet,
"\n";
}


I dont know if it is reaching the api.
Maybe everything gets parsed except for line 8?

Tom

0 new messages