On Tue, Jul 08, 2003 at 03:34:12PM +0100, Richard Lamb wrote:
> Hi folks,
> I'm Richard Lamb, and I'm a Perl virgin. Just getting to know the
> language. I'm in the midst of an MSc in Computing in Manchester (UK),
> working out a means of stripping HTML tags (via the DOM interface, which
> I'm trying to get to grips with) and reformatting text, so as to improve
> a Web site's accessibility (particularly the visually impaired). Are
> there any PPMs you'd recommend I check-out?
I have only tried HTML::TreeBuilder (not DOM, but the same principle;
uses heuristic HTML parsing and patching that does some unwanted things)
and XML::LibXML (which has the advantage of using the libxml2 library
that other languages also bind to; supports a lot of DOM plus some
extensions).
There are many more XML libraries, some with DOM in their names,
but they always fail to install on my Solaris system.
Here is my first XML::LibXML script, a HTML reformatter:
#!/usr/bin/env perl
use XML::LibXML;
my $parser = new XML::LibXML;
$parser->validation(1);
$parser->expand_entities(0);
$parser->keep_blanks(0);
$parser->pedantic_parser(1);
$parser->expand_xinclude(0);
foreach my $srcdoc (@ARGV ? @ARGV : ('-'))
{
my $doc = $parser->parse_html_file($srcdoc);
print $doc->toStringHTML();
}
# end of script
> Cheers,
>
> Richard.
Enjoy,
--
Reinier