with the XML code below:
def soapResponse = "
<Results>
<ResultSet fetchSize="10">
<Row rowNumber="1">
<ID_ORDER>144107</ID_ORDER>
<CH_LNAME>TESTING</CH_LNAME>
<CH_FNAME>QA</CH_FNAME>
</Row>
<Row rowNumber="2">
<ID_ORDER>144108</ID_ORDER>
<CH_LNAME>TESTING</CH_LNAME>
<CH_FNAME>QA</CH_FNAME>
</Row>
</ResultSet>
</Results>
"
def inputXML = new XmlParser().parseText(soapResponse)
I want to use a GPath to get the value of ID_ORDER under the first Row (Row rowNumber="1").
This works, the below variable is populated with 144107:
def id_order = inputXML.ResultSet.Row[0].ID_ORDER
However, I need to be able to construct that GPath from an excel sheet. But when I populate the Excel cell with ResultSet/Row[0]/ID_ORDER and perform the above line as a variable:
def excelVariable = //getting "ResultSet/Row[0]/ID_ORDER" from sheet
def excelVariableArray = excelVariable.split('/') //create array of it, separated by "/"
def id_order = inputXML."${excelVariableArray[0]}"."${excelVariableArray[1]}"."${excelVariableArray[2]}".text() //traverse through XML, get value of "ID_ORDER" under 1st "Row"element
Here id_order is not populated. The expectation is that it would populate with 144107. If I take the index "[0]" out of the Row[0], then it successfully grabs all of the ID_ORDER values from the XML. But since I only want the 1st one, I use the index 0 but it doesn't work - value comes out empty.
Hoping someone can chime in with a resolution to this.