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

Re: Reading multi-level-tag XML file

by poj (Abbot)
on Jul 27, 2015 at 15:29 UTC ( [id://1136481]=note: print w/replies, xml ) Need Help??


in reply to Reading multi-level-tag XML file

Using XML::Twig
#!perl use strict; use warnings; use XML::Twig; use Data::Dump 'pp'; my %hash=(); my $twig = new XML::Twig( twig_handlers =>{ 'SellerInformation' => \&info } ); $twig->parsefile('test.xml'); pp \%hash; sub info { my ($t,$e) = @_; my $id = $e->first_child("Seller")->att('sellerIdFromProvider'); my $col = $e->first_child("TaxableLocationsCollection"); for my $loc ($col->descendants("TaxableLocation")){ push @{$hash{$id}}, $loc->att('locationValue'); } }
poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1136481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-28 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found