def string = ''' ''' def xml = new XmlSlurper().parseText(string) def map = ['03062': 'ABC', '03092': 'ABC', '03144': 'ABC'] criteria = xml.'**'.find {'Criterion' == it.name()} criteria.appendNode { map.each { k, v -> HotelRef('ChainCode' : v, 'HotelCode': k) } } println groovy.xml.XmlUtil.serialize(xml)