Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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>

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]
[Happy-the-monk]: LanX; you did?
[Discipulus]: ah! plastering thanks..
[LanX]: I'd need english subtitles ... like with most English speaking movies...
[choroba]: LanX Sure, without subtitles, it's just a half of the movie :-)
Discipulus is lazy.. Eatly has optimal dubbing service.. never saw an OV english movie..

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2018-02-19 10:59 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (262 votes). Check out past polls.