I would like to extract all text elements which appear directly as a child node to the root node. I've had a glance at java standard sax fascilities using DefaultHandler
; but it doesn't seem like it's path aware.
The problem is getting first-level only
nodes, not extracting only text-nodes.
Is there any non-DOM oriented approach to do this? (Note, the node names are not known in advance)
[EDIT]
Sample input
<root>
<a>text1</a>
<b>text2</b>
<c>text3</c>
<nested>
<d>not_text4</d>
...
<nested>
...
</root>
Sample output
Map<String, String> map := {
{a, text1}
{b, text2}
{c, text3}
}
Currently solved as a DOM oriented workaround. Although there exist libraries which offers a subset of xpath expressions for SAX / STAX.