Forum Discussion

deepthireddy's avatar
deepthireddy
New Contributor
5 years ago

Groovy SCript for taking specific tag values into getDOMNodes

I have below response from SOAP UI <m:bansArray> <m:item> <m:ban>4382640110 056</m:ban> <m:banNickname></m:banNickname> <m:billingAddressLine1>10500 RYAN</m:billingAddressLine1> <m:billingAddre...
  • HimanshuTayal's avatar
    5 years ago

    Hi deepthireddy :

     

    Hope you will get help from below code 🙂

     

    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
    
    def holder = groovyUtils.getXmlHolder( "SOAP Request#Response" )
    
    def nodes = holder.getDomNodes( "//*" )
    
    def XMLlist = []
    
    for( node in nodes )
    {
    	if(!(node.getNodeName().toString().contains("m:serviceCodeEnglishDescription")  || node.getNodeName().contains("m:serviceCodeFrenchDescription") || node.getNodeName().contains("m:transpromoStatus")) ){
    		def value = com.eviware.soapui.support.xml.XmlUtils.getNodeValue( node )
    		if((value!=null))
    		{
    			if( !(value.isAllWhitespace()))
    				XMLlist.add(value)
    		}
    	}
    }
    def Slist = XMLlist.size()
    log.info "SOAP UI RESPONSE" + XMLlist