Smaug has asked for the wisdom of the Perl Monks concerning the following question:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Import format="3.0" fileId="54630000-3141-1404-4310-7F0000014030" fil +eCreationDateTime="2012-07-23T06:04:31.415" catalogSource="TLCMz"> <Catalog> <Vendors> <Vendor name="Allen Systems" vendorUniqueKey="ALLENGRP"/> <Vendor name="Aonix North America" vendorUniqueKey="AONIX"/> <Vendor name="Beta Systems Software" vendorUniqueKey="BETASY +S"/> <Vendor name="BMC Software" vendorUniqueKey="BMC"/> </Vendors> </Catalog> </Import>
use strict; use warnings; my $xmldoc = XMLin("C:\\dsys.xml"); print Dumper($xmldoc);
Which returns a reference to the hash (I think), but I can' t seem to find a way to step through the data in the hash. When I try:my $vendors = "$xmldoc->{'Catalog'}->{'Vendors'}";
my $vendors = "$xmldoc->{'Catalog'}->{'Vendors'}"; foreach my $vendor (@{$vendors->{Vendor}}) { print $vendor->{name} . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with attributes and XML::Simple
by Anonymous Monk on Aug 01, 2012 at 08:25 UTC | |
by Smaug (Pilgrim) on Aug 01, 2012 at 08:39 UTC | |
|
Re: Help with attributes and XML::Simple
by ig (Vicar) on Aug 01, 2012 at 08:42 UTC | |
by tobyink (Canon) on Aug 01, 2012 at 10:02 UTC | |
|
Re: Help with attributes and XML::Simple
by Athanasius (Archbishop) on Aug 01, 2012 at 09:08 UTC | |
by Anonymous Monk on Aug 01, 2012 at 15:55 UTC | |
|
Re: Help with attributes and XML::Simple
by Jenda (Abbot) on Aug 01, 2012 at 16:11 UTC |