I am having xml something like this with nested tags.
<content level="2">
<data>abc</data>
<content level="3">test3</content>
<content level="2">test2</content>
<content level="4">test4</content>
</content>
Irrespective of parent/child tags I want to split xml based on attribute value. i.e I want xml from level 2 to next level 2 as one chunk and remaining child tags as another chunk. my output should be something like below. Is it possible?
<content level="2">
<data>abc</data>
<content level="3">test3</content> -- is one chunk
and
<content level="2">test2</content>
<content level="4">test4</content> -- is another chunk
I tried XPATH with [@level=2] but unfortunately for first chunk it is giving total xml as parent tag contains whole content but I don't want it, i would like to extract only level to level.
I also tried with vtdnav.getContentFragment byusing offset and length and it is still same case where I am getting whole xml as one chunk.