Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Struggling with XML

by runrig (Abbot)
on Oct 05, 2012 at 16:03 UTC ( #997506=note: print w/replies, xml ) Need Help??

in reply to Struggling with XML

Another way, w/XML::Rules:
use XML::Rules; my @rules = ( list => sub { my $dict = $_[1]{dict}; for my $d (@$dict) { print "$d->{key}: $d->{value}\n"; } return; }, dict => [ '/root' => sub { my $d = $_[1]; print "$d->{key}: $d->{value}\n" if $d->{key} eq 'status'; return; }, 'no content array', ], value => 'content', ); my $xr = XML::Rules->new( rules => \@rules ); $xr->parse($xml);
Updated to also print status. A possibly simpler way(?):
my @rules = ( "^dict" => sub { return $_[1]{key} =~ /^(?:status|subnet|gateway|netmask|data)$/; }, dict => sub { my $d = $_[1]; return if $d->{key} eq 'data'; print "$d->{key}: $d->{value}\n"; }, value => 'content', );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997506]
[Corion]: LanX: Ow ;)
Discipulus manual work: i just tell the same to my boss: every time the quick solution is to assign some manual data entry task to my group.. because we have not direct access to many databases here..
[LanX]: point is: in high speed trade each bank has to remember what he has to get from the others... so dresdner got billed for losses but couldn't claim gains
Discipulus is this the IT?
[Corion]: Discipulus: Well, in many cases it doesn't make sense to build an interface and complicated program just to enter 20 rows into a database ;) But yes, automating data imports should pay off in the long run
[LanX]: Choroba: this happened before I joined, was still in uni, but my boss was summoned to the CEO of the second biggest German bank at that time and could only say " I told them its not ready" ;)

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-03-29 12:02 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (350 votes). Check out past polls.