Forum Discussion
nmrao
Champion Level 3
Also you check this example which is done some recently and same as yours ie., xml contains cdata and it contains json.
http://stackoverflow.com/questions/35623183/soapui-how-to-find-node-count-in-json-response/35626696#35626696
Other examples to get the json data
https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/AssertJsonArrayElement.groovy
Sphujidhwaj
9 years agoContributor
import com.eviware.soapui.support.XmlHolder import net.sf.json.groovy.JsonSlurper respXmlHolder = new XmlHolder(messageExchange.getResponseContentAsXml()) respXmlHolder.declareNamespace("ns1","http://tempuri.org/") CDATAXml = respXmlHolder.getNodeValue("//ns1:Result") log.info(CDATAXml) def data = new XmlSlurper().parseText(CDATAXml).Result log info "data.findAll{it.Completed Date}.size()"
When I try executing the above code I get an error "Content is not allowed in Prolog"
Also what if there is space in between the Value as shown below "Completed Date" instead of "CompletedDate"
- nmrao9 years agoChampion Level 3Have you tried putting it in quotes?
jsonData.Report.each { log.info it.'Completion Date'}- Sphujidhwaj9 years agoContributor
Yes,
But even before that I get an error Content is not allowed in Prolog.
I am not able to resolve this to check whether the above code gives the desired output.
Thanks,
SD
- nmrao9 years agoChampion Level 3May be you want to show the exact response, probably raw?