Dizzo
7 years agoOccasional Contributor
Need help with XmlSlurper
Hello guys, I hope you can help me with parsing xml report by Groovy XmlSlurper. I need to get maximum date of issuance of ID card. Can anybody help, im noob in this, it's so hard to me. ...
- 7 years ago
XmlHolder was easier because I wasn't sure about sorting nodes in XmlSlurper.
To filter the nodes and sort the dates in an array
def xml = new XmlSlurper().parseText(response) docs = xml.Result.Root.IdentificationDocuments.Document.findAll { it.Name.@value == 'ID card' && it.DateOfIssuance.@value != '-' } dates = [] docs.each {dates.add it.DateOfIssuance.@value.text()} log.info dates.sort { Date.parse('dd.MM.yyyy', it ) }.reverse()[0]
- 7 years ago
Dizzo,
Looks got what you mean to say.
Below Script Assertion would show id and max DateOfIssue.
https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/xml/QueryRelativeData.groovyYou can quickly try it online as well using below link.