Forum Discussion
PaulDonny
12 years agoRegular Contributor
This will log and ignore all of your CDATA stuff (I hate CDATA) and will output only the 'child' nodes (In your example, companyName and modelNumber).
it[1] is your element and it[2] is the value. If you want something more specific to grab, for example, only the modelNumber, edit the regex to correspond to that or add in an if (it[1].equals(tag)) { }. There is better ways but I like to use groovy scripts.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder("CData Test#Response");
def xml = holder.getPrettyXml()
def regexp = ("<([^<>]+)>(.*?)</\\1>");
def matcher = xml =~ regexp;
matcher.each {
log.info it[1]
log.info it[2];
}
it[1] is your element and it[2] is the value. If you want something more specific to grab, for example, only the modelNumber, edit the regex to correspond to that or add in an if (it[1].equals(tag)) { }. There is better ways but I like to use groovy scripts.