Forum Discussion

vinodtiwari10's avatar
New Member
9 years ago

How to save response data in Excel/CSV format in SOAP UI 5.2.1?



I am getting response when hitting request in XML format. I want to store that XML or save that XML in CSV or Excel format.




3 Replies

  • Layansan's avatar
    New Contributor

    You need to use an Excel API to communicate or manipulate data in the Excel files.

    Download Java Excel API and place the JXL.jar file in the “lib” folder of your SoupUI installation directory. 


    Assume the response is like: 

    <Response xmlns="http://localhost/something">
       <content>some content</content>

    Add a Groovy test step

    import jxl.*
    import jxl.write.*
    def groovyUtils = new context )
    def holder = groovyUtils.getXmlHolder("RequestStep#ResponseAsXml") // Change RequestStep name holder.getXml()  // will display /Log the response in Xml
    WritableWorkbook workbook = Workbook.createWorkbook(new File("C:/output.xls"))
    WritableSheet sheet = workbook.createSheet("Worksheet 1", 0)
    xPath1 = "//*:id/text()"     // use xPath to access the value from response
    xPath2 = "//*:content/text()" holder.getNodeValue(xPath1) holder.getNodeValue(xPath2)
    Label label = new Label(0, 1, holder.getNodeValue(xPath1)); //column=0,row=1
    Label label1 = new Label(2, 2, holder.getNodeValue(xPath2)); //column=2,row=2
    • ddineesh's avatar
      New Contributor

      its working just fine for me. Thanks a lot for this article.

    • LearnAutomation's avatar
      New Member

      I am able to extract the text from a tag and save it in excel using your code. But it will format the entire excel...I am trying to save the extracted response value in a particular cell in my test case. But when i run the code, all the other values in that particular excel sheet is removed and only the extracted soap response is saved.. can you help please!!