【问题标题】:Update namespace of xml column更新 xml 列的命名空间
【发布时间】:2012-10-07 16:34:33
【问题描述】:

重构后我发现它需要改变现有数据的命名空间。每个 db 行包含具有如下数据的列:

<Bla xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.contoso.com/ooo/entities/v1">
   <Titles>
      <smth sourceId="19" targetId="2">
         <smth2>New</smth2>
      </smth>
   </Titles>
</Bla>

如何将值xmlns="http://schemas.contoso.com/ooo/entities/v1" 更新为xmlns="http://schemas.contoso.com/ooo/common/v1"

实际的例外是InvalidOperationException(没有预期的命名空间)。 m.b 可以更改数据读取器的反序列化,但是...

【问题讨论】:

    标签: .net sql-server xml


    【解决方案1】:
    update MyTable
    set MyColumn = 
    Convert(xml,
        REPLACE(
            Convert(nvarchar(max), MyColumn),
            'http://schemas.contoso.com/ooo/entities/v1',
            'http://schemas.contoso.com/ooo/common/v1')
        )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多