XML::Simple Parsing with Attributes problem #2

  • Follow


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



0
Reply John 2/3/2006 11:39:34 AM

"John" <john@heathdrive.com> wrote:
> 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

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB
0
Reply xhoster 2/3/2006 4:39:34 PM


1 Replies
79 Views

(page loaded in 0.049 seconds)

Similiar Articles:













7/24/2012 3:16:23 AM


Reply: