How can I print the duplicate tags values using jdom API? For instance having this XML:
<xml>
<text> Hello Jdom</text>
<tag>Jdom</tag>
<tag1>hi</tag1>
<tag1>bye</tag1>
</xml>
How can I save both 'tag1' values into an array of strings and print them both? I've tried to use "node.getChildText("tag1");" but it just always takes the first tag's value and omit the other?
The trick here is to use the List outputs.... consider:
List<String> values = new ArrayList<>()
for (Element tag : node.getChildren("tag1")) {
values.add(tag.getText())
}
System.out.println(values.toString())