def xml = """
<testsuites name="" tests="10" time="20.137">
<script/>
<script/>
<testsuite name="test1" id="3b582d64-0d1a-4016-a482-a02ec2c993c0" timestamp="2021-11-22T12:30:11.253Z" tests="2" failures="0" errors="0" time="1.235">
<testcase name="Status code is 200" time="1.235" classname=""/>
<testcase name="validate time response" time="1.235" classname=""/>
</testsuite>
</testsuites>
"""
def rootNode = new XmlParser().parseText(xml)
Hello, I need to read the information from the xml I found a way to parse it but I can't read the data below
I need to read the time of the testcase
Anyone who can guide me, thank you
CodePudding user response:
def rootNode = new XmlParser().parseText(xml)
rootNode.testsuite.each{tsuite->
println "suite name = ${tsuite.@name}; time = ${tsuite.@time}"
tsuite.testcase.each{tcase->
println " case name = ${tcase.@name}; time = ${tcase.@time}"
}
}