I have the following XML snippet:
<topic>
<data attribute1="1">some data 1<data>
<data attribute1="1">some data x<data>
<data2 type="sometype">some data 2</data2>
</topic>
<topic>
<data attribute1="1">some data 1<data>
<data attribute2="2">some data 2<data>
</topic>
I'd like to generate a super XML node from these topics
such that the final output is a single topic
with elements grouped by attribute, element names and values:
<topic>
<data attribute1="1">some data 1<data>
<data attribute1="1">some data x<data>
<data2 type="sometype">some data 2</data2>
<data attribute2="2">some data 2<data>
</topic>
What's the best approach to achieve this? Could I use XQuery? I've been playing around with http://basex.org/ but not had much luck.