I am novice in groovy scripting however trying to get some repetitive work done by automating a generation of an XML file creation.
So the question is:
I have an excel data source step in ready api and i would like to parametrize all values so they are passed to groovy script. At present if i hard code the values in script, XML is formed as per schema however I need to iterate through all data in excel. so my test suite currently contains the following structure:
- Data source
- Groovy Script
- Data Source Loop
I would like my data read each row at a time which will build XML elements as needed. So far I have the following code in script:
//package test
import groovy.xml.MarkupBuilder
/**
* A Simple Example that builds an XML document.
*/
class Test
{
static main(args)
{
def fileWriter = new FileWriter("c:/test.xml")
def fileBuilder = new MarkupBuilder(fileWriter)
fileBuilder.Header
{
date ('')
Item
{
SKU('')
Description('')
Amt('')
Qty('')
}
}
fileWriter.close()
}
}
Looking forward to hearing from experts on this.
Thanks