XML::Simple Parsing with Attributes problem

J

John

Hi - problem parsing with an attribute name.

<england>
<town code="LON">Capital City</town>
<town code="MAN">Manchester</town>
<town code="BHAM">Birmingham</town>
</england>

I'm using XML::Simple.

$xml = new XML::Simple (ForceArray=>1, suppressempty=>1);
$data = $xml->XMLin($xmlfile);

$which=$data->{england}->[0]->{town}->[0]; doesn't work.

I need to access both attribute value and its contents (BHAM and
Birmingham).

Any ideas?

John
 
X

xhoster

John said:
Hi - problem parsing with an attribute name.

<england>
<town code="LON">Capital City</town>
<town code="MAN">Manchester</town>
<town code="BHAM">Birmingham</town>
</england>

I'm using XML::Simple.

$xml = new XML::Simple (ForceArray=>1, suppressempty=>1);
$data = $xml->XMLin($xmlfile);

$which=$data->{england}->[0]->{town}->[0]; doesn't work.

I need to access both attribute value and its contents (BHAM and
Birmingham).

Any ideas?

use Data::Dumper;
print Dumper $data;

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top