in reply to Re: XML::LibXML Parser Error
in thread XML::LibXML Parser Error

Yes, this still is experiencing the same issue, hence a fresh thread. I have tried to eval of the parser and this does not seem to make any difference. Attempting multiple times will occasionally work, but it can still work on the first try or fail after the 10th try. I need some other discussions on what else can be attempted and if this may be a common issue with a common solution. Has anyone else run into this issue before?

Replies are listed 'Best First'.
Re^3: XML::LibXML Parser Error
by hippo (Archbishop) on Mar 07, 2014 at 16:50 UTC

    Failure of HTTP requests hasn't been new since 1991 ;-) so test the response:

    use LWP; my $url = 'http://feeds.feedburner.com/oreilly/perl?format=xml'; my $agent = LWP::UserAgent->new; my $request = HTTP::Request->new(GET => $url); $request->content_type('application/xml'); my $response = $agent->request($request); if ($response->is_success) { print "HTTP response is good\n"; # Parse XML here } else { die "Awooga! HTTP request failed with ". $response->status_line; }
      I understand that. But it isn't failing the HTTP response...Output:
      HTTP response is good parser error : Document is empty parser error : Start tag expected, '<' not found
      The XML starts off properly with a <> tag everytime...

        So, check the content as well:

        my $xml = $response->content; if ($xml =~ /^</) { print "Looks like it could be xml/html\n"; # Parse xml here } else { die "Bad content:\n$xml\n"; }

        In fact, save the content on each invocation so you can see why it isn't parsing or what the difference is.