I have a not specified number of nested categories, which contain items:
<categories>
<category>abc
<category>cde
<item>someid</item>
<item>someid</item>
<item>someid</item>
<item>someid</item>
</category>
</category>
<category>xyz
<category>zwd
<category>hgw
<item>someid</item>
...
The result should be a list of items which are in the most deeply nested category (cde or hgw). Tricky is that there can be more than two level of nesting of categories and I want to save each parent category for the child category.
I already did some xml parsing with Jackson XmlMapper and ObjectMapper, but this use case seems out of reach. So I tried it with javax xml parser but gave up, because the code looks horrible and is hardly readable.
Any idea how to solve this in a more elegant way?