简体   繁体   中英

Modify existing records

Is there any way to update the value of each node in xml file like this:

<RootNode>
  <Item>test1</Item>
  <Item>test2</Item>
  <Item>test3</Item>
</RootNode>

that is actually xml column in table to the following:

<RootNode>
  <Item><![CDATA[test1]]></Item>
  <Item><![CDATA[test2]]></Item>
  <Item><![CDATA[test3]]></Item>
</RootNode>

There is an XML way, but it might be easier to convert the XML field to varchar and then:

 @var = replace(@var,'<item>','<item><![CDATA[')

and then

@var = replace(@var,'</Item>',']]></Item>')

both of which could be performed in one statement, but it would depend on the rest of the XML data, how much data you're wanting to update and the resources available etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM