Solved

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

Posted on 2011-03-01
1
520 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 500 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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

717 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