Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: XML::Twig won't parse my url

by ambrus (Abbot)
on Jan 06, 2011 at 10:11 UTC ( [id://880785]=note: print w/replies, xml ) Need Help??


in reply to XML::Twig won't parse my url

You need to tell XML::Twig explicitly that you want to parse XML, not HTML. There probably should be a parseurl_html method (there's parse_html and parsefile_html), but it's missing, so you need one of the following workarounds:

$twig->safe_parseurl_html($url) or die;
OR
use LWP::Simple; $twig->parse_html(get($url) or die "error downloading HTML");

Update: Fixed parse to parse_html, sorry. Also, as you already get the html above, you only need $twig->parse_html($html). Though I'd recommend $twig->safe_parseurl_html($url, $agent) or die instead because that way it sure gets the encoding right.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://880785]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 18:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found