Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

parse xml and trigger function modules.

by balajinagaraju (Sexton)
on Apr 09, 2012 at 04:18 UTC ( #964078=perlquestion: print w/ replies, xml ) Need Help??
balajinagaraju has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks. I tried several ways to parse the below XML but was not successful in doing so, i am new to XML and perl and i am seeking an help here. My task is to parse the below xml structure.My script has to perform the below operations. 1)Goto Testcase1 and access the step1 and perform the command mentioned in step1 with the provided parameters.The command is defined in another perl file as a function module and it should be triggered with the specified parameters.My script should perform step2 based on the return value of command1 if its success it should execute command 2 else exit from the script and goto testcase2. I am absolutely clueless about the approach i should take , can anyone suggest how to solve this. A code snippet would be very helpful.

<testcase1> <step1 command ="Launchapp " param1 = "executablepath" param2 = "d +irpath"/> <step2 command = "Dothis"/> <step3 command = "Changemode" param1 = "100"/> <step4 command = "CaptureRectanlge" param1 = "3" param2 = "96" par +am3 = "726" param4 = "580"/> <step5 command = "CompareImage" image1 = "D:\\img1.jpg" image2 = " +D:\\img2.jpg "/> </testcase1> <testcase2> <step1 command ="Launchapp " param1 = "executablepath" param2 = "d +irpath"/> <step2 command = "Dothis"/> <step3 command = "Changemode" param1 = "100"/> <step4 command = "CaptureRectanlge" param1 = "3" param2 = "96" par +am3 = "726" param4 = "580"/> <step5 command = "CompareImage" image1 = "D:\\img1.jpg" image2 = " +D:\\img2.jpg "/> </testcase2>

Comment on parse xml and trigger function modules.
Download Code
Re: parse xml and trigger function modules.
by Anonymous Monk on Apr 09, 2012 at 04:25 UTC

    Hi Monks. I tried several ways to parse the below XML but was not successful in doing

    Great, show your efforts :)

      I tried it using XML::Simple but this gives me a hash reference which is basically a unsorted datastructure, i used XML::Parser as well but it went above my head.. :-). Now trying to use XML::Twig.This seems to be pretty handy but wanted to gather information on the best available and a easy way to do it.

        XML::Twig is frequently recommended and is well documented with lots of example code. Show us what you have tried and we will help correct your code. You will get much better help and learn a lot more that way than having us write a chunk of code for you.

        True laziness is hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://964078]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2014-10-25 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (138 votes), past polls