我有以下 XML,在 SOAPUI Groovy 中,我尝试去捕获一组带有标签和值的 XML,例如:
<telephoneNumbers>
<telephone>
<id>125042741</id>
<areaCode>0161</areaCode>
<phoneNumber>4804420</phoneNumber>
<extension>1234</extension>
<usage>Work</usage>
</telephone>
</telephoneNumbers>
我试图返回以下结果(标签和值):
<telephone>
<id>125042741</id>
<areaCode>0161</areaCode>
<phoneNumber>4804420</phoneNumber>
<extension>1234</extension>
<usage>Work</usage>
</telephone>
这是时髦的:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def Recall = groovyUtils.getXmlHolder( "Recall#Response" )
def telephone = Recall[ "//telephone//*" ] as String
String returnXml = ""
if ( Recall["//restrict"] != null ) {
returnXml= telephone
}
else
return returnXml