Forum Discussion
Radford
7 years agoSuper Contributor
I like to use the XmlSlurper to parse XML data, here is a standalone example with your data:
import groovy.util.XmlSlurper
def xmlData = '''\
<Results>
<ResultSet fetchSize="128">
<Row rowNumber="1">
<UNIQUEID>80382049</UNIQUEID>
<SOURCESYSTEM>HitsSC</SOURCESYSTEM>
<ROUTEID>39812</ROUTEID>
<SHIFTDATE>2018-12-07 00:00:00.0</SHIFTDATE>
</Row>
<Row rowNumber="2">
<UNIQUEID>80382096</UNIQUEID>
<SOURCESYSTEM>NTExchange</SOURCESYSTEM>
<ROUTEID>39812</ROUTEID>
<SHIFTDATE>2018-12-07 00:00:00.0</SHIFTDATE>
</Row>
<Row rowNumber="3">
<UNIQUEID>80382097</UNIQUEID>
<SOURCESYSTEM>NTExchange</SOURCESYSTEM>
<ROUTEID>39812</ROUTEID>
<SHIFTDATE>2018-12-07 00:00:00.0</SHIFTDATE>
</Row>
<Row rowNumber="4">
<UNIQUEID>80382098</UNIQUEID>
<SOURCESYSTEM>NTExchange</SOURCESYSTEM>
<ROUTEID>39812</ROUTEID>
<SHIFTDATE>2018-12-07 00:00:00.0</SHIFTDATE>
</Row>
</ResultSet>
</Results>'''
def Results = new XmlSlurper().parseText(xmlData)
Results.ResultSet.Row.each(){row ->
log.info('UNIQUEID = ' + row.UNIQUEID + '; ROUTEID = ' + row.ROUTEID)
}del_exaclee
7 years agoNew Contributor
Thanks for this Radford. A couple of things:
1) I need the code to dynamically take its input from a JDBC response as this code will need to run 100 times for our test requirements so I need to parse the JDBC response as XML dynamically.
2) Once I have extracted that data from the JDBC response, can I populate this data into a single test case property so that I can inject it into a SOAP request?
Regards,
Ajay