Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Replace XML tag names.

by Anonymous Monk
on May 03, 2010 at 15:11 UTC ( [id://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>

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-18 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found