I need to pass XML data through a filter that will transform the character data but leave the tags as-is. (The transform involves converting certain ASCII characters to utf8 Arabic characters, so I have to make sure this doesn't apply to the tags).
XML::Parser, with the "Style" set to "Stream" makes this very easy and clear, but there's one problem: if the input contains empty tags like this:
<sometag attr1="v1" attr2="v2"/>
it'll come out looking like this:
<sometag attr1="v1" attr2="v2"></sometag>
Am I just being too picky? Is it too much to ask that empty tags be kept empty? Here's a brief snippet that demonstrates the behavior:
use XML::Parser;
$xml = qq{<tag attr="xyz"/>};
print "original: $xml\n";
$parser = new XML::Parser( Style => 'Stream' );
print "parsed: ";
$parser->parse( $xml );
print "\n";
sub StartTag { print }