I want to try an retrieve the name of a hotel (in this example the hotel is called 'Test Hotel'), but I am unsure how to do it because I believe to get a @node it's using @ but how do I retrieve a text?
Below is the xml:
<xxx xmlns:soap="xxx" xmlns:xsi="xxx" xmlns:xsd="xxx">
<xxx>
<xxxxmlns="xxx">
<AvailabilityRS Url="xxx" IntCode="xxx">
<Results>
<HotelResult Code="xxx"DestinationZone="xxx">
<HotelInfo>
<Name>Test Hotel</Name>
Below is the script:
def response = testRunner.testCase.getTestStepByName("xxx").getProperty("Response").getValue()
def parsedxml = new XmlSlurper().parseText(response)
def hotelName = parsedxml.'soap:Body'.HotelAvailResponse[0].xxx[0].Results[0].xxxx[0].xxx[0].Name[0].toString()
Instead of using toString()
, you should be able to just use text()
def hotelName = parsedxml.Body
.HotelAvailResponse
.AvailabilityRS
.Results
.HotelResult
.HotelInfo
.Name.text()
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments