title: Groovy script xml parser for multiple files
body: <p>Hi my groovy script strips out an xml tag from a file and writes to a file.</p>
  
  <pre><code> import org.apache.commons.lang.RandomStringUtils
   import groovy.util.XmlSlurper
  
  
  
   inputFile = 'C:\\sample.xml'
   outputFile = 'C:\\ouput.txt'
  
  
   XMLTag='Details'
  
   fileContents = new File(inputFile).getText('UTF-8')
  
   def xmlFile=new XmlSlurper().parseText(fileContents)
  
   def myPayload= new String(xmlFile.'**'.find{node-&gt; node.name() ==    XMLTag}   *.text().toString())
  
  
   file = new File(outputFile)
   w = file.newWriter() 
   w &lt;&lt; myPayload.substring(1, myPayload.length()-1)
   w.close()
  </code></pre>
  
  <p>My question is how do I write it so the it goes through an entire directory and performs it on multiple xml files and creates multiple output as at the moment it is hard coded. ('C:\sample.xml' and 'C:\ouput.txt')</p>
  
  <p>Thanks</p>
  
  <p>Leon</p>