Skip to content

Instantly share code, notes, and snippets.

@hoehrmann
Created January 23, 2013 14:45
Show Gist options
  • Save hoehrmann/4607023 to your computer and use it in GitHub Desktop.
Save hoehrmann/4607023 to your computer and use it in GitHub Desktop.
#!perl -w
use strict;
use warnings;
use XML::LibXML;
use XML::LibXSLT;
use autodie;
my ($html_path, $xslt_path) = @ARGV;
my $html_doc = XML::LibXML->load_html( location => $html_path, recover => 2, load_ext_dtd => 0 );
my $xslt_doc = XML::LibXML->load_xml( location => $xslt_path );
my $xslt = XML::LibXSLT->new();
my $stylesheet = $xslt->parse_stylesheet($xslt_doc);
my $results = $stylesheet->transform($html_doc);
binmode STDOUT;
print $stylesheet->output_as_bytes($results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment