Is it possible to extract the node name using apache digester?
So, if the xml looks like
<furniture>
<sofa>
.....
</sofa>
<coffeeTable>
.....
</coffeeTable>
</furniture>
is it possible to extract the node name “sofa”, “coffeeTable”?
I know it is possible using xpath but is it possible using digester?
Cheers
(original answer)
Create a
Digesterfor pattern"furniture/*"with a simpleRulethat takes the second parameter to each call to the begin method and sticks it in a collection of your choice (a list to get all of them, a set to get only all unique names).(edit)
Scratch that, it’s a bit more complicated.
This works:
This particular sample will print all element names including the root
furnitureelement. I’ll leave it to you to adjust thematch()method to your needs.