XML::Simple Parsing with Attributes problem

Discussion in 'Perl Misc' started by John, Feb 3, 2006.

  1. John

    John Guest

    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
    John, Feb 3, 2006
    #1
    1. Advertising

  2. John

    Guest

    "John" <> 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
    , Feb 3, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. phantom
    Replies:
    2
    Views:
    352
    Lutz Horn
    May 11, 2004
  2. Andy Carson
    Replies:
    8
    Views:
    389
  3. Replies:
    3
    Views:
    2,836
  4. John
    Replies:
    1
    Views:
    90
  5. Erik Wasser
    Replies:
    5
    Views:
    452
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page