Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3337938
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:18:49+00:00 2026-05-18T00:18:49+00:00

I have a Perl script that reads a XML file that doesn’t have content,

  • 0

I have a Perl script that reads a XML file that doesn’t have content, only attributes in the element.

Like this:

<league>
<game name="bla"/>
</league>

Now I try to get the game attribute ‘name’.

I tried using $xml->{league}->{game}->{name} and $xml->{league}->{game}->['name'] but they are both not working. Something about a hash problem.

Is there anybody who can help me get the value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:18:50+00:00Added an answer on May 18, 2026 at 12:18 am

    Well, from the XML you posted, I get this:

    Entity: line 3: parser error : Opening and ending tag mismatch: league line 0 and leage
    

    It doesn’t even appear to be a strict/warnings issue because it appears when I comment my USUW out.

    But if you have the right tags, this should work:

    $xml->{game}{name};
    

    And if I call XMLin with KeepRoot => 1, you’ll find it at:

        $xml->{league}{game}{name};
    

    If you are having trouble locating how the data is being read in, do this:

    use 5.010;
    use strict;
    use warnings;
    use Data::Dumper;
    use XML::Simple;
    
    my $xml = XMLin( $input );
    say Data::Dumper->Dump( [ $xml ], [ '$xml' ] );
    

    And then use the path to the structures presented.


    Note:

    $xml->{league}->{game}->['name'];
    

    should have died with: “Not an ARRAY reference at” even without warnings enabled. ['string'] is a reference to an array with the string 'string' as the sole element. And, if $xml->{league}{game} were an array, it would have died with a non-numeric error, because strings don’t address arrays.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a perl script that I need to tweak. The script runs and
I have a php script that handles a form input. For design reasons both
I would like a command line function that I can run on any file
I'm a Perl programmer with some nice scripts that go fetch HTTP pages (from
I currently have a USB card swipe attached to an embedded linux machine and
I have names of all files in output.txt but I do not have folderpath
Thanks to a suggestion from Chas. Owens , I have been having fun playing
I've got multiple access logs in the logs directory, following the naming convention below:
I was wondering if it's possible to actually print out the available ethernet cards
When developing on BlackBerry or iOS, you can deploy your application just by dropping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.