#!/usr/bin/perl -w # vim:set expandtab shiftwidth=4 softtabstop=2 tabstop=4: use strict; use Data::Dumper; use XML::LibXML; use XML::LibXSLT; use XML::XPath; my $xml_results = q{ Floor Floor 1Adobe Acrobat PDF File (PDF)
Local Time (24 hr)

}; # # Since there was a comment that there was no control over the source HTML.... # (and yes, I know it probably only works with the sample data).... # $xml_results =~ s/(=)([^\"\'\s\>]+)/$1"$2"/gis; $xml_results =~ s/(\)/$1\/$2/gis; $xml_results =~ s/(\]+)(>)/$1\/$2/gis; =pod # # For reference-the expressions worked with this # $xml_results = q{ Floor Floor 1Adobe Acrobat PDF File (PDF)
Local Time (24 hr)

}; =cut # # No user-editable data below this point. # $| = 1; # Initialize the parser and XSLT processor my $parser = XML::LibXML->new(); my $xslt = XML::LibXSLT->new(); my $source_doc = $parser->parse_string($xml_results); # Initialize the XPath processor my $xp = XML::XPath->new( xml => $xml_results ); my ($stylesheet); { my $stylesheetdata = q{ }; my $style_data = $parser->parse_string($stylesheetdata); $stylesheet = $xslt->parse_stylesheet($style_data); } my $result = $stylesheet->transform($source_doc); print $stylesheet->output_string($result);