Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > XML::Simple Parsing with Attributes problem

Reply
Thread Tools

XML::Simple Parsing with Attributes problem

 
 
John
Guest
Posts: n/a
 
      02-03-2006
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



 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      02-03-2006
"John" <(E-Mail Removed)> 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:umper;
print Dumper $data;

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
attributes ala java annotations or .Net attributes? Kyle Schmitt Ruby 3 07-24-2007 07:48 PM
class attributes & data attributes james_027 Python 2 06-20-2007 03:12 PM
WebControl.Attributes.Add and custom attributes P4trykx ASP .Net 2 01-31-2007 04:33 PM
Parse reserved attributes as normal attributes Max XML 1 09-22-2006 12:04 PM
XML::Simple Parsing with Attributes problem John Perl Misc 1 02-03-2006 10:47 PM



Advertisments