# XML::Driver::HTML # # Copyright (c) 2001 Michael Koehne # # XML::Filter::HTML is free software. You can redistribute and/or modify # this copy under terms of the GNU General Public License. use strict; use XML::Handler::YAWriter; use XML::Driver::HTML; use IO::File; use Digest::MD5; use vars qw($loaded %checksums $md5); BEGIN { $| = 1; print "1..2\n"; print "loaded ... "; } END { print "not ok 1\n" unless $loaded; } $loaded = 1; %checksums = ( 'www.xml-edifact.org-EX-index.xhtml' => "d35b7799a07fcf09da6b58a859949919", 'www.copyleft.de-index.xhtml' => "16bf4f246c4008c2e6b62f63693783ec", 'www.cpan.org-index.xhtml' => "fccc3b62707afa1deb7e6023a05d4a1a" ); print "ok 1\n"; #------------------------------------------------------------------------------# print "ByteStream ... "; my $ya = new XML::Handler::YAWriter( 'AsFile' => "www.xml-edifact.org-EX-index.xhtml", 'Pretty' => { 'AddHiddenNewline'=>1, 'AddHiddenAttrTab'=>1, 'CatchEmptyElement'=>1 } ); my $html = new XML::Driver::HTML( 'Handler' => $ya, 'Source' => { 'ByteStream' => new IO::File ( "parse(); $md5=Digest::MD5->new->addfile( new IO::File( "hexdigest; print $md5." ... "; print "not " if $md5 ne $checksums{'www.xml-edifact.org-EX-index.xhtml'}; print "ok 2\n"; #------------------------------------------------------------------------------# print "SystemId ... "; $ya->{'AsFile'} = "www.copyleft.de-index.xhtml"; $html->parse( 'Source' => { 'SystemId' => "www.copyleft.de-index.html", 'Encoding' => "iso-8859-1" } ); $md5=Digest::MD5->new->addfile( new IO::File( "hexdigest; print $md5." ... "; print "not " if $md5 ne $checksums{'www.copyleft.de-index.xhtml'}; print "ok 3\n"; #------------------------------------------------------------------------------# print "String ... "; $ya->{'AsFile'} = "www.cpan.org-index.xhtml"; delete $ya->{'Pretty'}{'NoComments'}; my $cpan_index = <<'INDEX_HERE'; Comprehensive Perl Archive Network

CPAN: Comprehensive Perl Archive Network

Welcome to CPAN! Here you will find All Things Perl.

CPAN is the Comprehensive Perl Archive Network. Comprehensive: the aim is to contain all the Perl material you will need. Archive: 760 megabytes as of September 1999. Network: CPAN is mirrored at more than one hundred sites around the world.


You can search all of CPAN. There are also alternative searching engines for CPAN and the documentation of all modules. You can also check the CPAN Frequently Asked Questions list.


Yours Eclectically
The Self-Appointed Master Librarian (OOK!) of the CPAN
Jarkko Hietaniemi
cpan@perl.org
[Disclaimer]
1999-03-05
INDEX_HERE $html->parse( 'Source' => { 'String' => $cpan_index } ); $md5=Digest::MD5->new->addfile( new IO::File( "hexdigest; print $md5." ... "; print "not " if $md5 ne $checksums{'www.cpan.org-index.xhtml'}; print "ok 4\n"; print "\tinvalid www.cpan.org-index.xhtml because of HTML::TreeBuilder\n"; 0;