0

I have an XML file that I am trying to parse through with Groovy.

<?xml version = '1.0' encoding = 'UTF-8'?>
    <ServerList>
        <Server>server1.me.com</Server>
           <CleanUpTest>TESTING</CleanUpTest>
        <Server>server2.me.com</Server>
    </ServerList>

This code works and gives me the output Result: [server1.me.com]:

def serverList = new XmlSlurper().parse("E:\\Program Files(x86)\\Jenkins\\jobs\\first_servers.xml")

def output = []
serverList.Server.find { it == 'server1.me.com' }.each{
     output.add(it)
}

return output

But when I try to get the value in CleanUpTest it is not working.

def serverList = new XmlSlurper().parse("E:\\Program Files(x86)\\Jenkins\\jobs\\first_servers.xml")

def output = []
serverList.Server.find { it == 'server1.me.com' }.CleanUpTest.each{
     output.add(it)
}

return output

What do I have wrong? I am expecting Result: [TESTING]

Ryan Johnson
  • 109
  • 1
  • 2
  • 8

0 Answers0