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

  • SEARCH
  • Home
  • 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

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?

  • 0 0 Answers
  • 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 simple xml file that looks like this: <?xml version=1.0 encoding=UTF-8 standalone=yes
I have a Perl script that reads a command file and restarts itself if
I have a Perl script that I'd like to run on Windows, using either
I have written a Perl script that reads some data and generates an OpenOffice
I have a Perl script that reads data from an Excel ( xls )
Sorry, if this to verbose, but I have a perl script that is partly
I have a Perl script that I'm attempting to set up using Perl Threads
I have a Perl script that sets up variables near the top for directories
I have a Perl script that pops up a message box when its work
I have an existing Perl script that uses the FTP object to send a

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.