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

Re: Easily XML filtering?

by GrandFather (Sage)
on May 06, 2008 at 22:48 UTC ( #685087=note: print w/replies, xml ) Need Help??

in reply to Easily XML filtering?

Set up twig handlers for them. Consider:

use strict; use warnings; use XML::Twig; my $xml = <<XML; <companies> <Acme>Acme</Acme> <Missing>Missing</Missing> <Wobbler>Wobbler</Wobbler> <Trump>Trump</Trump> <Tibble>Tibble</Tibble> </companies> XML my @companyList = qw(Acme Wobbler Tibble); my %handlers = map {$_ => \&HandleCompany} @companyList; my $twig = XML::Twig->new (twig_handlers => \%handlers); $twig->parse ($xml); sub HandleCompany { print $_->text (), "\n"; }


Acme Wobbler Tibble

Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^2: Easily XML filtering?
by mattr (Curate) on May 07, 2008 at 18:10 UTC
    Thank you very much, I'll study Twig too for sure.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://685087]
[erix]: you seem forget there is another idiot coming :)
[Your Mother]: The US government does not attract talent, but grafters and liars and it has been that way for the better part of a century. FEW exceptions.
[erix]: you think it only /looks/ worse this time?
[Your Mother]: HR Clinton was literally threatening Russia. She would have been MUCH more likely to start real trouble.
[Your Mother]: I think there is less decorum this time.
[Your Mother]: We’ve had rapists and thieves and unqualified government. They just had decorum.
[erix]: heh, understatement of the week :)
[erix]: well, I hope you're right
[Your Mother]: Bill Clinton assaulted and raped repeatedly. Even when it was hinted and finally all but proved, no one cared because his sexism, and racism, and killing was decorous.
[Your Mother]: I think Trump might be better specifically because no one respects him so he won't get his way the way the others did.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-01-20 01:01 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (173 votes). Check out past polls.