XML::Driver::HTML - SAX Driver for non wellformed HTML.
use XML::Driver::HTML; $driver = new XML::Driver::HTML( 'Handler' => $some_sax_filter_or_handler, 'Source' => $some_PerlSAX_like_hash ); $driver->parse();
or
use XML::Driver::HTML; $driver = new XML::Driver::HTML(); $driver->parse( 'Handler' => $some_sax_filter_or_handler, 'Source' => $some_PerlSAX_like_hash ); $driver->parse( 'Handler' => $some_other_sax_filter_or_handler, 'Source' => $some_other_source );
XML::Driver::HTML is a SAX Driver for HTML. There is no need for the HTML input to be weel formed, as XML::Driver::HTML is generating its SAX events by walking a HTML::TreeBuilder object. The simplest kind of use, is a filter from HTML to XHTML using XML::Handler::YAWriter as a SAX Handler.
my $ya = new XML::Handler::YAWriter( 'Output' => new IO::File ( ">-" ), 'Pretty' => { 'NoWhiteSpace'=>1, 'NoComments'=>1, 'AddHiddenNewline'=>1, 'AddHiddenAttrTab'=>1, } ); my $html = new XML::Driver::HTML( 'Handler' => $ya, 'Source' => { 'ByteStream' => new IO::File ( "<-" ) } ); $html->parse();
Creates a new XML::Driver::HTML object. Default options for parsing, described below, are passed as key-value pairs or as a single hash. Options may be changed directly in the object.
Parses a document. Options, described below, are passed as key-value pairs or as a single hash. Options passed to parse() override the default options in the parser object for the duration of the parse.
The following options are supported by XML::Driver::HTML :
Default SAX Handler to receive events
Hash containing the input source for parsing. The `Source' hash may contain the following parameters:
The raw byte stream (file handle) containing the document.
A string containing the document.
The system identifier (URL) of the document.
A string describing the character encoding.
If more than one of `ByteStream', `String', or `SystemId', then preference is given first to `ByteStream', then `String', then `SystemId'.
XML::Driver::HTML requires Perl 5.6 to convert from ISO-8859-1 to UTF-8.
not yet implemented:
Interpretation of SystemId as being an URI XHTML document type
other bugs:
HTML::Parser and HTML::TreeBuilder bugs concerning DOCTYPE and CSS. Perl handling of UFT8 is compatible between different versions. So you need exactly Perl 5.6.0, not lower not higher.
Michael Koehne, Kraehe@Copyleft.De (c) 2001 GNU General Public License
XML::Parser::PerlSAX and HTML::TreeBuilder
To install XML::Driver::HTML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Driver::HTML
CPAN shell
perl -MCPAN -e shell install XML::Driver::HTML
For more information on module installation, please visit the detailed CPAN module installation guide.