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 8713653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:23:41+00:00 2026-06-13T05:23:41+00:00

I am trying to parse an XML file. The Xml file can be found

  • 0

I am trying to parse an XML file. The Xml file can be found @ http://pastebin.com/fvuwbrh9.
I have saved this xml file as packages.xml.

Goal: List all the names which are surrounded by <packagereq> tag in the XML (I am referring the packagereq which fall under the group in the dumper output).

I wrote below script called rpm.pl:

#!/usr/bin/perl -w

use strict;
use XML::Simple;
use Data::Dumper;

my $ref = XMLin ('packages.xml');
#print Dumper ($ref);

foreach my $a ( keys %{ $ref->{group} } )
{
    if ( exists $ref->{group}->{$a}->{packagelist} )
    {
        foreach my $b ( @{ $ref->{group}->{$a}->{packagelist}->{packagereq} } )
        {
            print $b->{content}."\n";  ### <<< referring the Dumper out put
        }   
    }
}

Now my script goes half way throgh and prints the package names but then it gets terminated with below error:

Not an ARRAY reference at rpm.pl line 29.

After above error, the script does not process rest of the XML file and terminates.

Above error makes me believe that somewhere value of $ref->{group}->{$a}->{packagelist}->{packagereq} is not an ARRAY reference.

I have gone as carefuly as I can throguh the XML file (OR the Dumper output) but found that packagereq always points to an ARRAY reference unless and of course I overlooked something but I doubt so.

Could you provide some input on why is it complaining about Not an ARRAY ref.

Thanks.

  • 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-06-13T05:23:42+00:00Added an answer on June 13, 2026 at 5:23 am

    XML::Simple, the most complicated XML parser to use. Add the following:

    my $ref = XMLin ('packages.xml',
       KeyAttr    => [qw( id )],
       ForceArray => [qw( group packagereq ignoredep )],
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse this XML file for a school project: http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/topsongs/limit=10/genre=20/xml .
I have an XML file that I am trying to parse with Sax (this
I am trying to parse this xml (http://www.reddit.com/r/videos/top/.rss) and am having troubles doing so.
I'm trying to parse an xml file with PHP. I'm using this code and
I am trying to parse an XML file in java, after I have to
I am beginner in PHP. I am trying to parse this xml file. <relationship>
I have an XML file that I'm trying to parse with Linq-to-XML. One of
I am trying to parse the XML file in R, so that I can
I am trying to parse an xml file with xslt. I need to have
i am trying to parse this xml file into an object to use the

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.