I am using XMLParser for the first time to retrieve a response from an xml:
Below is the code:
import groovy.xml.XmlUtil
def response = testRunner.testCase.getTestStepByName("GetTestStep").getProperty("Response").getValue();
def root = new XmlParser().parseText( response )
log.info root
The log.info of root displays the following xml response:
:{http://schemas.xmlsoap.org/soap/envelope/}Envelope[attributes={}; value=[{http://schemas.xmlsoap.org/soap/envelope/}Body[attributes={}; value=[{http://www.xxx}TestHotelResponse[attributes={}; value=[{http://www.xxx}AvailabilityRS[attributes={Url=http://xxx.xxxxxxxx.com }; value=[{http://www.xxx.es/xxxxxx/2007/}
Now I want to be able to retrieve the attribute for AvailabilityRS
, However I keep getting a blank [] when I try to retrieve it via this method:
root.AvailabilityRS*.value()*.each { k, v ->
log.info ("$k.localPart = $v")
}
RAW XML:
<soap:Envelope xmlns:soap="http://schemas.xxx">
<soap:Body>
<xxx xmlns="http://www.xxx7/">
<xxx Url="http://xxx.xxxxxx.com">
How can I retrieve the Url within the attribute for AvailabilityRS?
Thanks,