Need to parse xml test script in Ruby

Hi,

I am writing ruby script to automate my unit testing. I have written
test case and expected output inside the xml file.

Now I need to parse it and execute the commands/instruction in xml
through my script.

Xml File:

<inject row="Record 1.1 for Table" <inject row="Record 1.2 for Table" Spd Request 1.1 Spd Request 1.2 Verify log 1.1 Spd Request 1.3 Verify log 1.2 <inject row="Record 2.1 for Table" Process Spd Request 2.1 Verify log 2.1 <inject row="Record 2.2 for Table" Process Spd Request 2.2 Verify log 2.2 ... ... ... ...

Now I want output like below(Inside each case, I am printing all
elements one by one SEQUENTIAL).
===============OUTPUT MUST BE IN BELOW ORDER===========
Executing case 01
Record 1.1 for Table
Record 1.2 for Table
Spd Request 1.1
Spd Request 1.2
Verify log 1.1
Spd Request 1.3
Verify log 1.2

Executing case 02
Record 2.1 for Table
Process Spd Request 2.1
Verify log 2.1
Record 2.2 for Table
Process Spd Request 2.2
Verify log 2.2

Please help me how do i write ruby script of this kind of output. Also
like inside each case at any point I should be able to process
input_file(i.e case-01.txt for case 1 or case-02.txt for case 2).

Please help me with some simple solution. Thanks in Advance!!

Thanks,
Ranganadhan

I suggest you look up the Nokogiri gem and its XML parsing capabilities.

For input test cases why don’t you try something like: ruby script.rb <<
input.txt

Ps. Instead of XML have you tried working with YAML? Is so much easier
and faster using YAML and Ruby.