http://www.perlmonks.org?node_id=938859


in reply to Modify XML tags

Hi. Is there a way to change all tags and attributes in XML to lower case?

Sure, here is a start

#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; my $str = <<'EOF'; <NoTe> <To> <Person>Satan</Person> </To> <Beef><SaUsAGe>is Tasty</SaUsAGe></Beef> </NoTe> EOF { my $t = XML::Twig->new( pretty_print => 'indented', force_end_tag_handlers_usage => 1, start_tag_handlers => { _all_ => sub { $_->set_tag( lc $_->ta +g ); return }, }, end_tag_handlers => { _all_ => sub { $_->set_tag( lc $_->tag +); return }, }, ); $t->parse($str); $t->flush(); } __END__

(Faced XPath feature being case-insensitive)

Why is this a problem?