I am trying to update a specific column in a table that has multiple namespaces in it. My table structure is:
+------+---------+-----------------------------------------------------------------------+
| cid | cidtype | xml_data |
+------+---------+-----------------------------------------------------------------------+
| 1001 | N | <Main xmlns:json=""http://www.samplenamespace.com/json"" > |
| | | <ID json:ValueType=""Number"">1001</ID> |
| | | <details> |
| | | <name xmlns:json=""http://www.samplenamespace.com/json"">John</name> |
| | | <age xmlns:json=""http://www.samplenamespace.com/json"">12</age> |
| | | </details> |
| | | </Main> |
| 1003 | N | <Main xmlns:json=""http://www.samplenamespace.com/json"" > |
| | | <ID json:ValueType=""Number"">1003</ID> |
| | | <details> |
| | | <name xmlns:json=""http://www.samplenamespace.com/json"">Diane</name> |
| | | <age xmlns:json=""http://www.samplenamespace.com/json"">25</age> |
| | | </details> |
| | | </Main> |
| 1004 | N | <Main xmlns:json=""http://www.samplenamespace.com/json"" > |
| | | <ID json:ValueType=""Number"">1004</ID> |
| | | <details> |
| | | <name xmlns:json=""http://www.samplenamespace.com/json"">Kippy</name> |
| | | <age xmlns:json=""http://www.samplenamespace.com/json"">26</age> |
| | | </details> |
| | | </Main> |
+------+---------+-----------------------------------------------------------------------+
In this table, I want to alter the xml_data
column to remove the http://www.samplenamespace.com/json
namespaces to all the subnodes except <Main>
node.
My query:
update #final --#final is my table
set xml_data.modify(replace('xmlns:json="http://www.samplenamespace.com/json"',' ','') where.... ) -- I don't know to access the root node here
Any help?