Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Replacing XML Tag name with another

by j0se (Pilgrim)
on Sep 27, 2011 at 12:21 UTC ( #928077=note: print w/ replies, xml ) Need Help??


in reply to Replacing XML Tag name with another

Developing Ratazong's comment:

#!/usr/bin/perl use strict; use warnings; # file given as command line argument my $file = shift @ARGV; die "Usage: $0 <file.xml>\n" unless $file; # step 1: open the file open FH, "<", $file or die "Can't open '$file': $!\n"; # step 2: read the file line-by-line while (<FH>) { # step 3: do the replacements s/<(\/?)H([12])>/<$1Heading $2>/g; # step 4: write the results the STDOUT print; } close FH;
Cheers, j


Comment on Re: Replacing XML Tag name with another
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2015-07-06 22:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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









    Results (83 votes), past polls