in reply to How can I read in XML Attributes.

What you have is not valid XML without quotes around the '4' and '5'. But you can parse like so:
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);
Update: And read the docs as mirod suggests to possibly get the data structure produced more to your liking.

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.

Replies are listed 'Best First'.
Re: Re: How can I read in XML Attributes.
by basicdez (Pilgrim) on Sep 11, 2001 at 00:39 UTC
    Sorry about the oversight of "s around the attributes. Thanks for your help however. peace dez L