Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I parse an xml file in Perl in a smart way using Perl modules

Posted on 2011-03-01
1
Medium Priority
?
528 Views
Last Modified: 2012-05-11
Hi,
I have a Perl code which uses some soap web services and it returns the following output:

$VAR1 = {
          'createdBy' => 'tolgar',
          'subComponent' => 'mycomp',
          'geckId' => '123456',
          'comments' => '',
          'solution' => 'SOME TEXT IN HERE',
          'keywords' => ''
        };

Open in new window



Now I want  to  parse this XML file in the solution field and return the 'SOME TEXT IN HERE'. How can I do it without using regular expressions? Instead are there any modules in Perl that does parsing on an XML file?

Can you give me a simple example?

Thanks,
0
Comment
Question by:Tolgar
1 Comment
 
LVL 25

Accepted Solution

by:
clockwatcher earned 2000 total points
ID: 35012476
That's not an XML file.  That appears to be a Data::Dumper output of a hash reference.  What code is giving you that output?  Guessing it looks like:

   print Dumper($somevar);

If that's the case, then:

   print $somevar->{'solution'};

will give you the SOME TEXT IN HERE.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question