Update: And read the docs as mirod suggests to possibly get the data structure produced more to your liking.use strict; use XML::Simple; use Data::Dumper; my $xml = <<EOT; <Begin> <Here ID="4">This is the start...</Here> <There REF="5">This is the middle...</There> </Begin> EOT my $xs = XML::Simple->new; my $data = $xs->XMLin($xml); print "$data->{Here}{ID}\n"; print "$data->{There}{REF}\n"; print Dumper($data);
Its up to you whether you want to use the functional interface as mirod did, or the OO interface as I did. XMLin() calls new() when called functionally, so if you're parsing many documents in a script, its better IMO to call new() once (possibly with some options) to get a parsing object, then parse all the documents with that one object. If you're only parsing one document in a script, then you may as well use the functional interface.
In reply to Re: How can I read in XML Attributes.
by runrig
in thread How can I read in XML Attributes.
by basicdez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |