i need to add encoding="ISO-8859-1" to the first line of XML data
I always make confusion with XML terminology and traversing, but this quick hack works:
use strict; use warnings; use XML::Twig; my $twig=XML::Twig->new( twig_handlers => { 'termEntry/langSet'=>sub{print $_[1]->att('xml:lang'), ": ", $_[1]->first_child('termGrp')->te +xt, "\n" } }, ); $twig->parse( \*DATA ); __DATA__ <?xml version="1.0" encoding="ISO-8859-1"?> <DB> <termEntry> <ShortInfo>Ciao</ShortInfo> <langSet xml:lang="Italian"> <termGrp> <term>Ricerca scientifica</term> </termGrp> </langSet> <langSet xml:lang="English"> <termGrp> <term>research</term> </termGrp> </langSet> </termEntry> <termEntry> <ShortInfo></ShortInfo> <langSet xml:lang="Italian"> <termGrp> <term>università</term> </termGrp> </langSet> <langSet xml:lang="English"> <termGrp> <term>university</term> </termGrp> </langSet> </termEntry> </DB>
L*
In reply to Re: Parsing XML::Simple
by Discipulus
in thread Parsing XML::Simple
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |