Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

parse xml and trigger function modules.

by balajinagaraju (Sexton)
on Apr 09, 2012 at 04:18 UTC ( [id://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>

Replies are listed 'Best First'.
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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-19 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found