There are multiple ways to do what you want, one of the ways is demonstrated below.
In this i make use of scriptom and consider the xml as a string and perform basic string concatenation. If you provide more details on a specific way of resolving your question or teh structure of your excel i'll be able to implement a solution based on that. In the meantime here goes my generic solution.
/*
* Script to convert excel into xml
* Related to: http://stackoverflow.com/questions/22031375/reading-excel-and-writing-to-xml-in-groovy-for-soapui
* Author: Abhishek Asthana
* Contact: http://abhishekasthana.com/about/
* License:
* * This program is free software. It comes without any warranty, to
* * the extent permitted by applicable law. You can redistribute it
* * and/or modify it under the terms of the Do What The Fuck You Want
* * To Public License, Version 2, as published by Sam Hocevar. See
* * http://www.wtfpl.net/ for more details.
*
* This script will read an excel(Any version, i used a .XLSX) and generate an xml where each row will be a node and
* each column will be its child node. The resulting xml will look something like this.
*
* <excel2Xml>
* <row1>
* <Column>cellValue</Column>
* <Column>anotherCellsValue</Column>
* <row1>
* <row2>
* <Column>cellValue</Column>
* <Column>anotherCellsValue</Column>
* <row2>
* </excel2Xml>
*
* Dependency:
* 1. Scriptom Library
* - Download: http://groovy.codehaus.org/COM+Scripting
* - Instructions to configure scriptom: http://stackoverflow.com/questions/18724929/how-to-make-scriptom-work-with-soapui
*
*/
import org.codehaus.groovy.scriptom.*
import org.codehaus.groovy.scriptom.util.office.ExcelHelper;
def excelPath = "C:\\soapUI\\excel2XML\\source.xlsx"
def dataSheetName = "Sheet1"
def oExcel = new ActiveXObject('Excel.Application')
Thread.sleep(1000)
assert oExcel != null, "Excel object not initalized"
def openWb = oExcel.Workbooks.Open(excelPath) //get access to the workbook
def dtUsedRange = openWb.Sheets(dataSheetName).UsedRange //get the usedRange of the sheet
int rCount = dtUsedRange.Rows.Count
int cCount = dtUsedRange.Columns.Count
def strXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><excel2Xml>"
//add property names to xlMapSheet under col d or col# 4
for(int r = 1;r<=rCount;r++){
strXml = strXml + "<row" + r.toString() + ">"
for(int c = 1;c<cCount;c++){
def cValue = openWb.Sheets(dataSheetName).Cells(r,c).Value
strXml = strXml + "<Column>" + cValue + "</Column>"
}
strXml = strXml + "</row" + r.toString() + ">"
}
strXml = strXml + "</excel2Xml>"
log.info strXml
openWb.Close(false,null,false)
oExcel.Quit()
Scriptom.releaseApartment()
This returns the below XML
<?xml version="1.0" encoding="UTF-8"?>
<excel2Xml>
<row1>
<Column>row1Col1</Column>
<Column>row1Col2</Column>
<Column>row1Col3</Column>
<Column>row1Col4</Column>
<Column>row1Col5</Column>
<Column>row1Col6</Column>
</row1>
<row2>
<Column>row2col1</Column>
<Column>row2col2</Column>
<Column>row2col3</Column>
<Column>row2col4</Column>
<Column>row2col5</Column>
<Column>row2col6</Column>
</row2>
<row3>
<Column>row3Col1</Column>
<Column>row3Col2</Column>
<Column>row3Col3</Column>
<Column>row3Col4</Column>
<Column>row3Col5</Column>
<Column>row3Col6</Column>
</row3>
</excel2Xml>
Do note that i have not implemented any error handling and if you were to use this code you would have to do that on your own.