xml 元素删除问题
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
')
注意蓝色处是需要修正的! 想要得到上面的运行结果...