Contributions
Re: Extracting data from CData in SOAP Response
def alert = com.eviware.soapui.support.UISupport; def inputFile = new File("C:\\Test.xml") if(!inputFile.exists()) { alert.showInfoMessage("Input File 'Test.xml' not found!"); } else { def InputXML = new XmlParser().parseText(inputFile.text) def InputRow = InputXML.ReportResult.findAll{it.'Group Name'.text().size() } InputRow.each{log.info(it.'Group Name'.text()); } } I have tried the above code but I get result as -Script-result: [] Let me know where I am going wrong. Note: The Test.xml contains the Soap Response with data enclosed in CDATA Thanks, SD2.5KViews0likes5CommentsRe: Extracting data from CData in SOAP Response
As mentioned in the first post this is the XML Response ouput. <ReportResponse xmlns="http://tempuri.org/"> <ReportResult><![CDATA[{ "Report": [ { "Name": "ABC", "Number": "123", "Type": "XYZ", "Desc": "EFGH", "Group Name": "Name123", "Group Number": "123", "End Date": "12/30/2014", "Due Date": "04/15/2015", "Completion Date": null, "Status": "Status1", "Received Date": "", "Delivery Date": "", "Location": "", "Role": "", }, { "Name": "EFG", "Number": "123", "Type": "XYZ", "Desc": "EFGH", "Group Name": "Name123", "Group Number": "123", "End Date": "12/30/2014", "Due Date": "04/15/2015", "Completion Date": null, "Status": "Status1", "Received Date": "", "Delivery Date": "", "Location": "", "Role": "Manager", }, When I try extracting the names using script assertion. I get error Content is not allowed in Prolog. In the preceding post, I had pasted the output from SoapUI sorry for the confusion. Thanks, SD2.5KViews0likes7CommentsRe: Extracting data from CData in SOAP Response
Cannot post the content as it is very huge (exceeds more than 5000 lines) but can paste the part of the output. this is how it looks: Tue Mar 22 13:50:38 IST 2016:INFO:{ "Rpt": [ { "Name": ",", "Number": " ", "Type": "", "Desc": "Desc", Grp Name": " ", Thanks, SD2.5KViews0likes9CommentsRe: Extracting data from CData in SOAP Response
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 "CompletedDate" instead of "CompletedDate"2.6KViews0likes13CommentsRe: Extracting data from CData in SOAP Response
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, SD7.8KViews0likes0Comments