Groovy web console

subscribe to the feed Subscribe
to this
site
xml test (via #groovywebconsole)
tweet this snippet Tweet
this
script

xml test

Published 5 months ago by nmrao with tags xml
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
String record = ''' <collections>   <material>     <books>       <title>Italy</title>     </books>   </material>   <material>     <books>       <title>Greece</title>     </books>     </material>   <material>     <books>       <author>Germany</author>     </books>     </material>     <material>     <cd>       <author>France</author>     </cd>     </material>   </collections> '''
def materials = new XmlSlurper().parseText(record).material.findAll { it.books.title.size() }
materials.each { println groovy.xml.XmlUtil.serialize(it) }