First page Back Continue Last page Overview Image

Syntactic sugar: XML

XMLSlurper

def myXmlString = '''

<transaction>

<payment>

<txID>68246894</txID>

<customerName>Huey</customerName>

<accountNo type="Current">15778047</accountNo>

<txAmount>899</txAmount>

</payment>

</transaction>

'''

def transaction = new XmlSlurper().parseText(myXmlString)

assert transaction.payment.txAmount == '899'

assert transaction.payment.accountNo.@type == 'Current'

assert transaction.payment.accountNo == '15778047'

assert transaction.payment.txID == '68246894'