I have multiple data items, each with a value V that has multiple tags associated with it–t1,t2…tn. I have an XML file where I choose to store each item and the tags associated with it, e.g.
<root>
<item>
<value>V1</value>
<tag>t11</tag>
<tag>t12</tag>
<tag>t13</tag>
</item>
<item>
<value>V2</value>
<tag>t21</tag>
<tag>t22</tag>
</item>
...
</root>
I want to be able to easily query for values V when I search for tags. How can I do this efficiently without writing entire libraries of code?
If you have control over your XML, I would restructure it like this:
This way you could simply write an XQuery like this to get all the tags for a given value: