?
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
?
524 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
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
Suggested Courses

777 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