Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: HTML tidy, using XML::LibXML

by Matts (Deacon)
on Jan 04, 2003 at 17:10 UTC ( [id://224278]=note: print w/replies, xml ) Need Help??


in reply to HTML tidy, using XML::LibXML

If you've got sloppy HTML that needs tidying up and XML::LibXML barfs on it, you can change that one-liner to the following three-liner:
my $parser = XML::LibXML->new(); $parser->recover(1); # Set recovery on error flag $parser->parse_html_string(join "", <>)->toStringHTML;
XML::LibXML can also parse SGML. Most people don't know that (probably sucky docs ;-)

Replies are listed 'Best First'.
Re^2: HTML tidy, using XML::LibXML
by Your Mother (Archbishop) on Sep 01, 2007 at 05:43 UTC

    Don't know if it's accurate but the docs say that won't work-

    This switch (recover) will only work with XML data rather than HTML data.

    (Update, July 2010: this does work and has for at least a few years -- don't know if it was always the case; I should have tested back when I initially responded.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 17:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found