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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:52:13+00:00 2026-05-31T09:52:13+00:00

I want to parse an XML file using Perl . I was able to

  • 0

I want to parse an XML file using Perl. I was able to do it using the XML::Simple module, but now I want to start using the XML::XPath module instead because it uses XPath expressions. From my limited knowledge I think XPaths will make future parsing easier, right?
Here’s the Perl code I have so far:

use strict;
use warnings;
use XML::XPath;

my $file = "data.xml";
my $path = XML::XPath->new(filename => $file);

my $name = $path->find('/category/event/@name');
print $name."\n";

My question is how do I separate each name attribute (category/event/@name) so that I can perform tests on each value I parse. At the moment I’m just getting a big string full of the parsed data, whereas I want several small strings that I can test. How can I do this? 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-05-31T09:52:14+00:00Added an answer on May 31, 2026 at 9:52 am

    This review points out that XML::XPath hasn’t been updated since 2003, and recommends XML::LibXML instead

    use 5.010;
    use strict;
    use warnings;
    use XML::LibXML;
    
    my $dom = XML::LibXML->new->parse_file('data.xml');
    for my $node ($dom->findnodes('/category/event/@name')) {
        say $node->toString;
    }
    

    See XML::LibXML::Parser and XML::LibXML::Node.

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

Sidebar

Related Questions

I'm using XML::Simple to parse an XML file which I then want to use
I have a simple but huge xml file like below. I want to parse
I'm using php to parse my xml file, all I want to be able
I want to parse some large XML file using linq to XML but I
I want to parse an XML file from URL using JDOM. But when trying
I am using GWT and want to parse an xml file, but I get
I want to parse a large XML file and I have two options: Perl
I have the following very simple XML file and I want to quickly parse
I want to parse (little critical) xml using php simplexml...But i can aither get
can i parse remote(not local) file using JS/Jquery? i want to display remote xml

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.