Created
October 21, 2016 09:20
-
-
Save fganora/5edf9aea69e18ba38e3a33c53be6ef55 to your computer and use it in GitHub Desktop.
Groovy: simple example of parsing and processing an XML document with XmlSlurper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def menu = new XmlSlurper().parseText(payload) | |
def totalPrice = 0.0 | |
(menu.food).each { | |
menuItem -> | |
totalPrice += Double.parseDouble(menuItem.price.text()) | |
} | |
totalPrice |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample input XML for this: