I am using BaseX to store XML data with multiple item
nodes in the following format:
<root>
<item id="Root" parent_id="0" type="folder">
<content>
<name>Root</name>
</content>
</item>
<item id="One" parent_id="Root" type="file">
<content>
<name>First File in the Tree</name>
</content>
</item>
<item id="Two" parent_id="Root" type="file">
<content>
<name>Second File in the Tree</name>
</content>
</item>
</root>
I am trying to update the parent_id
on one of the 'item' nodes to another item
node's id
attribute.
The tree before running the XQuery expression:
Root
∟ First File in the Tree
∟ Second File in the Tree
I am trying to figure out the correct XQuery expression to change the parent of one of the item
s from root
to "one" item
, so that my tree now looks like this:
Expected result tree:
Root
∟ First File in the Tree
∟ Second File in the Tree
Since the attribute parent_id
controls this, I am looking to update exactly that.