Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Replace XML tag names.

by ikegami (Pope)
on May 03, 2010 at 15:24 UTC ( #838132=note: print w/ replies, xml ) Need Help??


in reply to Replace XML tag names.

Using an different parser:

#!/usr/bin/perl use strict; use warnings; use XML::LibXML; { 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 $doc = XML::LibXML->new->parse_string($xml); for ($doc->findnodes('//*')) { my $name = $_->nodeName(); $name =~ tr/.//d; $_->setNodeName($name); } print($doc->toString()); }


Comment on Re: Replace XML tag names.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (18)
As of 2014-09-02 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (25 votes), past polls