graff has asked for the wisdom of the Perl Monks concerning the following question:
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:
it'll come out looking like this:<sometag attr1="v1" attr2="v2"/>
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:<sometag attr1="v1" attr2="v2"></sometag>
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 }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML::Parser can't create empty tags?
by merlyn (Sage) on May 06, 2005 at 05:39 UTC | |
Re: XML::Parser can't create empty tags?
by mirod (Canon) on May 06, 2005 at 07:39 UTC | |
Re: XML::Parser can't create empty tags?
by gube (Parson) on May 06, 2005 at 06:09 UTC | |
Re: XML::Parser can't create empty tags?
by dakkar (Hermit) on May 06, 2005 at 14:42 UTC |
Back to
Seekers of Perl Wisdom