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

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.

Replies are listed 'Best First'.
Re^6: XML::LibXML Parser Error
by omegaweaponZ (Beadle) on Mar 07, 2014 at 18:12 UTC
    So from initial testing, it seems that the parser will work fine when I write this to a temporary file, then read from that file, yet fail when reading directly from the web xml output. That seems completely counter intuitive. If I can read and write out proper xml everytime to a local file why can't the parser read and parse directly from the web xml output everytime!

    This still seems to suggest an error with the parser having issues from the web output even though the HTML returns correctly...

    However, what we can attempt to do is use this newly created string and parse as a string, instead of a location. That seems to bypass whatever issue has been causing problems, so we would use:

    $dom = XML::LibXML->new->load_xml(string => "$xml");
    Instead of the URL directly. This seems to do the trick.

    Thanks again for your help!

      That seems completely counter intuitive. If I can read and write out proper xml everytime to a local file why can't the parser read and parse directly from the web xml output everytime!

      webservers are free (and frequently do) give out nonsense frequently

      webserver is bartender

      you can ask webserver/bartender for milk, but he can give you nothing or a glass of cow urine -- webserver/bartender is free to be insane