Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: XML::Simple parsing help

by karlgoethebier (Prior)
on Dec 09, 2012 at 15:02 UTC ( #1007985=note: print w/replies, xml ) Need Help??


in reply to XML::Simple parsing help

Or give XML::Twig a try:

#!/usr/bin/perl + use strict; use warnings; use XML::Twig; my $file = shift; my $twig = XML::Twig->new( twig_handlers => { inventor => \&inventor } + ); $twig->parsefile($file); sub inventor { my ( $twig, $inventor ) = @_; if ( $inventor->first_child('number')->text eq "1" ) { print $inventor->first_child('country')->text . qq(\n) . $inventor->first_child('city')->text . qq(\n) . $inventor->first_child('upper-name')->text . qq(\n) . $inventor->first_child('name')->text . qq(\n); } } __END__
See also xmltwig.org

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007985]
help
Chatterbox?
talexb concurs .. almost 16 years here.
[TStanley]: Time flies when you're busy :D
LanX hasn't entered monk puberty yet
erix clocks 12 years
[TStanley]: talexb I was actually in your area last week. I was working in Milton, Ontario at the hospital they are building there.
Eily hasn't entered monk school

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2017-06-23 13:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (547 votes). Check out past polls.