I'm new to Grails/Groovy and am trying to find a node in a an xml file; I've figured out how to iterate over all of them, but I want to exit the loop when the target node is found. I've read that instead of using "each", use "find", but the find examples I've seen are conditions. Right now the logic I have is going to iterate through the whole file without exiting. The code is below:
records.children().each {domain ->
println "domain_name: " + domain.@domain_name
if (domain.@domain_name == targetDomain) {
println "target domain matched: " + domain.@domain_name
domain.children().each {misc_field ->
println "field_name: " + misc_field.@field_name
println "field_type: " + misc_field.@field_type
println "field_value: " + misc_field
}
}
}