假设我的xml响应如下:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetCitiesByCountryResponse xmlns="http://www.webserviceX.NET">
<GetCitiesByCountryResult><![CDATA[<NewDataSet>
<Table>
<Country>British Indian Ocean Territory</Country>
<City>Diego Garcia</City>
</Table>
<Table>
<Country>India</Country>
<City>Ahmadabad</City>
</Table>
<Table>
<Country>India</Country>
<City>Akola</City>
</Table>
<Table>
<Country>India</Country>
<City>Aurangabad</City>
</Table>
在这里,我希望使用SoapUi groovy脚本从包含<Country>
的根节点<Table>
名称获取<City>
元素值作为“Akola”。
答案 0 :(得分:2)
这样的东西?
import com.eviware.soapui.support.XmlHolder
def testCase = messageExchange.modelItem.testCase
def responseHolder = new XmlHolder(messageExchange.getResponseContentAsXml());
def resultFromServer = responseHolder["//Table/City[text()='Akola']/ancestor::Table[1]/Country/text()"]
答案 1 :(得分:1)
你也可以试试这个:
## set option to use digits for seconds
options(digits.secs = 2)
## convert your factor to a string and then to Posix format
tmp <- strptime(as.character(data$Time),'%H:%M:%OS')
## convert it to a numeric (unit seconds)
as.numeric(strftime(tmp,'%OS'))+60*as.numeric(strftime(tmp,'%M'))+60*60*as.numeric(strftime(tmp,'%H'))