#!/usr/bin/perl -w use strict; use XML::Parser; my $parser = new XML::Parser( Handlers => { Init => \&init, Start => \&start, End => \&end, Char => \&char, Final => \&final, Proc => \&proc, Comment => \&comment, CdataStart => \&cdstart, CdataEnd => \&cdend, XMLDecl => \&xmldecl, Doctype => \&doctype, } ); my $cdata; my $style = <<'_CSS_'; .element { font-weight: bold; color: red; } .attrname { font-weight: bold; font-style: italic; color: green; } .attrvalue { font-style: italic; color: green; } .comment { color: blue; } .proc { color: green; font-weight: bold; } .cdata { color: violet; } .doctype { font-weight: bold; color: brown; } .xmldecl { font-weight: bold; } _CSS_ if( $ARGV[0]) { $parser->parsefile( $ARGV[0]); } else { $parser->parse( \*STDIN); } sub init { print qq'
<?xml version="$v" encoding="$e" ' . qq'standalone="' .( $s ? 'yes' : 'no') . '"?>
'; } sub start { my ( $p, $e, %a ) = @_; print("