xml 元素删除问题

utopia54 CSDN会员 utopia54 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
declare @xmlCustomer xml
set @xmlCustomer =' <customer xmlns:C="http://schemas.mybook.com/customerschemas">
<item ID="1">
<customername>北方书城 </customername>
<address>北京市海淀区知春路22号 </address>
<phone>2222222 </phone>
<contact>刘先生 </contact>
</item>
</customer>'

-- 删除一个元素
SET @xmlCustomer.modify('
delete /customer/item[@ID=1]/phone
')
SELECT @xmlCustomer
运行结果是: <customer xmlns:C="http://schemas.mybook.com/customerschemas">
<item ID="1">
<customername>北方书城 </customername>
<address>北京市海淀区知春路22号 </address>
<contact>刘先生 </contact>
</item>
</customer>
===============================================
上面是正确的,疑问如下:
<C:customer xmlns:C="http://schemas.mybook.com/customerschemas">
<item ID="1">
<customername>北方书城 </customername>
<address>北京市海淀区知春路22号 </address>
<phone>2222222 </phone>
<contact>刘先生 </contact>
</item>
</C:customer>

-- 删除一个元素
SET @xmlCustomer.modify('
delete /customer/item[@ID=1]/phone
')

注意蓝色处是需要修正的! 想要得到上面的运行结果...
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
utopia54 CSDN会员
C# 111,129 成员 642,540 内容