I have an cucumber xml report and I want to extract the information in the attributes of the opening xml tag
the XML report looks like this
<testsuite failures="" name="" skipped="" tests="">
<testcase>
<skipped>
more tags but they are not relevant
</skipped>
</testcase>
</testsuite>
I want to be able to take the information from the testsuite attributes save them as java object so that I can put them in an email body that will be sent out to a mailing list.
the information provided in the testsuite xml tag is all I care about.
what would be the best way to approach this? I was creating a Testsuite class, annotating variables for the attributes I want with @XStreamAsAttribute and getting them that way but I am fairly unsure if this is correct.
I have no experience with xstream so trying to go with what information I can find online.
Update - have an issue in the function where I extract the xml attributes, only the last attribute name and value are being returned.
public String extractXMLReportAttributes() {
String messageBody = "";
for (int i = 0; i < nl.getLength(); i++) {
Attr a = (Attr) nl.item(i);
messageBody = String.format("%s: %s", a.getName(), a.getValue());
System.out.println(messageBody);
}
return messageBody;
}
An example using Java and XPath: