Compare 2 XML files and save the result to a single excel file in groovy

0

Good afternoon community,

I'm working with the Groovy language in the SoapUI NG Pro application and I came across a problem. My groovy script receives two responses to two requests to a web service. The output of the two responses are two .xml files I make comparisons normally and the response of this comparison, I wanted to make it a .xml file

This is the code that receives the answers and makes the comparison

import org.custommonkey.xmlunit.*

XMLUnit.setIgnoreWhitespace(true)
XMLUnit.setIgnoreComments(true)
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true)
XMLUnit.setNormalizeWhitespace(true)

def res1 = context.expand( '${SOAP Request Portefeuille REC#Response#declare namespace soapenv=\'http://www.w3.org/2003/05/soap-envelope\'; //soapenv:Envelope[1]}' )

def res2 = context.expand( '${SOAP Request Conseiller REC#Response#declare namespace soapenv=\'http://www.w3.org/2003/05/soap-envelope\'; //soapenv:Envelope[1]}' )

XMLUnit.compareXML(res1, res1)

This piece of code saves the result in an .xml file, but it is not in an xml format and I can not open it in a browser.

def directory = "C:/SoapOutput/"

new File(directory).mkdirs()

def compareFile = new PrintWriter (directory + "XML_compare.xml")
def comparation = XMLUnit.compareXML(res1, res2)
compareFile.print(comparation)
compareFile.flush()
compareFile.close()

I'm asking for suggestions or if someone knows a way to make the comparison response in xml format.

Thank you.

    
asked by anonymous 29.03.2018 / 18:17

0 answers