Forum Discussion
Hi Rup,
When I say names more than 500 it means the count of names,I have more than 500 blocks or chunks of names to be extracted.
Still I have not got there yet I am first trying to extract the data from the CData
But encountering the following message.
groovy.lang.MissingPropertyException: No Such Property: messageExchange for class: Script8 error at line 3
import com.eviware.soapui.support.XmlHolder respXmlHolder = new xmlHolder(messageExchange.getResponseContentAsXml()) respXmlHolder.declareNamespace("ns1","http://tempuri.org/") CDATAXml = respXmlHolder.getNodeValue("//ns1:Result") log.info(CDATAXml)
Please let me know where I am going wrong. Are there any links for the same where I can get some assistance in debugging such errors.
Thanks,
SD
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
- Sphujidhwaj9 years agoContributor
Hi,
CDATAXml = respXmlHolder.getNodeValue("//ns1:Result") log.info(CDATAXml) def data = new XmlSlurper().parseText(CDATAXml) def list = new groovy.json.JsonSlurper().parseText( data.toString()) log.info list.size()
When I try to run the above script I get an error "Content is not allowed in prolog"
The CDATAXml is very huge (I copied the content in text file it comes around 12000 lines)
Is the error due to huge data?
Please let me know if I am going wrong anywhere.
Thanks,
SD
- Sphujidhwaj9 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
Related Content
Recent Discussions
- 15 years ago