开发者

Inserting an attribute in all nodes of a xml using xml.modify

I need to read the whole xml one by one and then add attribute in every node of xml. Any idea how can I do this. I dont want to change开发者_StackOverflow the actuall xml. Just for the run time.


If you want to modify the XML you can use the insert XML DML.

UPDATE Table
SET xml_column = xml_column.modify('
  insert <foo>Some Text</foo>
  as first
  into (/some/path)[1]')

Note that .modify() can only appear in a update context (ie. an UPDATE statement or an SET statement), it cannot appear in a SELECT context.

If you want to project a modified XML without alering the actual XML in the database then you should not use the XML DML methods, but instead use XQuery and the .query() method. XQuery allows you to build on-the-fly a new XML based on the original XML, including adding new elements and attributes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜