Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Answer: Strip that XML!

by mirod (Canon)
on Dec 14, 2000 at 04:46 UTC ( #46535=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > Strip that XML! - Answer contributed by mirod

Using XML::Twig:

use XML::Twig; my $xml = <<EOF; <xml> <email>toto@foo.com</email><name>Toto</name> <email>tata@bar.com</email><name>Tata</name> <email>tutu@baz.com</email><name>Tutu</name> </xml> EOF my @email; my @name; my $twig = new XML::Twig( TwigHandlers => { email => sub { push @email, $_[1]->text; }, # $_[1] is the element + name => sub { push @name , $_[1]->text; } } ); $twig->parse( $xml ); print "email: @email\n"; print "name: @name\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (15)
As of 2016-08-31 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (432 votes). Check out past polls.