AnsweredAssumed Answered

How to split XML Element Nodes using Groovy By its Count

Question asked by siva9055 on Jul 31, 2018
Latest reply on Jul 31, 2018 by trey.yeager826393

Hi all,

            I'm trying to split XML Document Nodes using Groovy Scripting in the Data Process Shape by its count value. But I am not getting to split the nodes using this logic.


            Below you can see the XML data in that wanted to split it by person node count should be equal to People data maincount. And I've also posted my groovy script that I tried to get the count of child nodes and wanted to print it.



Here is the XML:


<main xmlns="" xmlns:xsi="">
<People xmlns="">


<person xmlns="">
    <kids count='2' />
  <person xmlns="">
    <kids count='0' />
  <person xmlns="">
    <kids count='3' />




And Here is My Groovy Code:


import groovy.xml.*


/ Hello World in Groovy /
println("Hello world")
def str = '''\XML Format should be passed from Dell Boomi


def xml = new XmlSlurper(false, true).parseText(str)




def contactNodes = xml.Body.People.person


def ccount =0


 xml.person.findAll {
 }.each {
     //println it.maincount.text()
 println  'person count :' +ccount
 def count =0
 xml.children().each {
     count ++;
  println count