Forum Discussion

ItP_1's avatar
ItP_1
Occasional Contributor
10 years ago

[Res] How to Read multiple XML files from a folder location

Hi,

I am facing a problem in reading multiple XML files within a folder using groovy scripting. I am able to read one file and make use of the contents of the file, but I am unable to read other files which are located in the folder.

Example:
I have 4 XML files (sample1.xml, sample2.xml, sample3.xml, sample4.xml) in a folder "Data". The 'Data' folder is located exactly where the soapui project is stored.

I am able to read sample1.xml using the below piece of code. And I also want to read the other 3 XML files sample 2.xml, sample3.xml, sample4.xml as well. Please help me achieve this.

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def projectPath = groovyUtils.projectPath //gets the path of the project root
def response = new File(projectPath, "/Data/sample1.xml").text;
log.info response


Thanks,
UMG ItP

4 Replies

  • ItP_1's avatar
    ItP_1
    Occasional Contributor
    Hi,

    Thanks for your response. I agree that I can use directory data source, but I want to accomplish this using Groovy script, since the customer who is going to use my project, doesn't use SoapUI Pro..they just use SoapUI OS. Please help me resolve this.

    Thanks,
    UMG ItP
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    Custom coding is outside the support agreement. Also, we provide support for SoapUI Pro and not the open source version. This functionality can be easily achieved by the client purchasing SoapUI Pro


    Regards,
    Marcus
    SmartBear Support