Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: How to filter XML elements, exclude some

by poj (Monsignor)
on Sep 13, 2013 at 13:01 UTC ( #1053919=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to filter XML elements, exclude some
in thread How to filter XML elements, exclude some

#!perl use strict; use XML::Twig; my $twig = new XML::Twig( twig_handlers => { 'item' => \&item } ); $twig->parsefile('in.xml'); $twig->set_pretty_print('indented'); $twig->print_to_file('out.xml'); sub item { my ($t,$e) = @_; for ($e->children){ $_->delete unless ($_->name =~ /^id|name$/); } }
poj

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053919]
help
Chatterbox?
[LanX]: White House indicates it could find funds to train 1 million teachers ...
[LanX]: ...no wait
[LanX]: White House indicates it could find funds to train and arm 1 million teachers!
LanX relieved...
[Discipulus]: too much guns in schools? throw more gun at schools! professors in arms

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2018-02-23 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (301 votes). Check out past polls.

    Notices?