#!/bin/perl -w use strict; use XML::Parser; use XML::Encoding; use XML::UM; # we need to tell XML::UM where the encoding maps are $XML::UM::SLowMapper::ENCDIR="/usr/local/src/XML-Encoding-1.01/maps2/"; my $encode; # the encoding function, created in the XMLDecl handler my $p= new XML::Parser( Handlers => { Start => \&default, End => \&default, XMLDecl => \&decl, Default => \&default, }, ); $p->parsefile($ARGV[0]); exit; sub default { my $p= shift; print $encode->($p->recognized_string()); } # get the encoding and create the encode function sub decl { my($p, $version, $encoding, $standalone)=@_; print "\n"; $encode= XML::UM::get_encode( Encoding => $encoding); }