So far, I haven't been able to extract the xml:lang attribute using XML::Parser. It seems to ignore attributes with the xml: prefix.My experience doesn't match yours. I can clearly see the attribute 'xml:lang' in the list of attributes.
Result:use XML::Parser; use Data::Dumper; my $parser = XML::Parser->new(Handlers => { Start => sub { print Dumper [ @_[1 .. $#_] ] } } ); $parser->parse(\*DATA); __DATA__ <FILE> <FOO xml:lang="en"> <BAR/> </FOO> <FOO xml:lang="ru"> <BAR/> </FOO> </FILE>
Anyway: you might be interested in using a parser that can handle XPath, as it might make filtering out just the contents you want, just a little bit easier.$VAR1 = [ 'FILE' ]; $VAR1 = [ 'FOO', 'xml:lang', 'en' ]; $VAR1 = [ 'BAR' ]; $VAR1 = [ 'FOO', 'xml:lang', 'ru' ]; $VAR1 = [ 'BAR' ];
Although personally, I think XML::Parser is fine... :)
In reply to Re: Parsing xml:lang attribute
by bart
in thread Parsing xml:lang attribute
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |