Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Replace XML tag names.

by Anonymous Monk
on May 03, 2010 at 15:11 UTC ( #838127=note: print w/ replies, xml ) Need Help??

in reply to Replace XML tag names.

#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; { my $xml = <<'__XML__'; <?xml version="1.0"?> <TOP> <SUB> <THIS>STUFF</THIS> <SOME.TYPE>T</SOME.TYPE> <SOME.OTHER.TYPE>BLAH</SOME.OTHER.TYPE> </SUB> </TOP> __XML__ my $t = XML::Twig->new( pretty_print => 'indented', twig_handlers => { '_all_' => sub { my ( $t, $e ) = @_; my $tag = $e->tag; if ( $tag =~ s/\.//g ) { $e->set_tag($tag); } $t->flush; ## does the printing return; }, }, ); $t->xparse($xml); $t->purge; undef $t; } __END__ <?xml version="1.0"?> <TOP> <SUB> <THIS>STUFF</THIS> <SOMETYPE>T</SOMETYPE> <SOMEOTHERTYPE>BLAH</SOMEOTHERTYPE> </SUB> </TOP>

Comment on Re: Replace XML tag names.
Download Code
Replies are listed 'Best First'.
Re^2: Replace XML tag names.
by Anonymous Monk on Aug 03, 2012 at 09:23 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://838127]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2015-07-28 19:15 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (258 votes), past polls