开发者

Wrap XML tags (insert around existing xml data) in xquery for eXist

Can anyone please help me with this xquery for eXist database. I have the following xml s开发者_如何学JAVAtructure

<A>  
   <B>  
     <D/>  
     <D/>  
     <D/>  
     <E/>  
  </B>  
</A> 

I'm trying to get the following structure

<A>  
   <B>  
    <C>  
     <D/>  
     <D/>  
     <D/>  
     <E/>   
    </C>   
  </B>  
</A>

How do I insert the <C> tag?

Thanks

--SD


I can't verify, but it should be so:

let $x := doc('namedocument.xml')/A/B
update insert <C>$x</C> into  doc('namedocument.xml')/A/B


You don't need XQuery Update to do this kind of operations.

This XQuery application:

<A>
 <B>
  <C>
  {for $n in /A/B/node()
   return $n}
  </C> 
 </B>
</A>

when applied on the provided XML document:

<A>      
  <B>
    <D/>
    <D/>
    <D/>
    <E/>
  </B>   
</A>  

produces exactly the wanted, correct result:

<A>
   <B>
      <C>
         <D/>
         <D/>
         <D/>
         <E/>
      </C>
   </B>
</A>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜