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
')
注意蓝色处是需要修正的! 想要得到上面的运行结果...
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
')
注意蓝色处是需要修正的! 想要得到上面的运行结果...
...全文
相关推荐
QXmlWrapper,实现XML文件的创建、删除以及元素节点的增加、删除、修改与查找等。
自己编写Qt的XML封装类QXmlWrapper,实现XML文件的创建、删除以及元素节点的增加、删除、修改与查找等。
解决XML节点删除后会留下一个空节点的问题
很短但是很实用 哈哈
对于xml的 删除改查
实现了对xml的删除改查实用 还是很实用的
java对XML文件的解析、节点的增加、删除操作总结
1、java代码: 主要采用dom来进行操作 代码如下: package test; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConf
XMLtoTree将xml加载到TreeView上(带添加和删除功能)
将xml加载到treeview,为了省事,我只是将xml的元素名加载到了TreeNode的txt中,当然,tag也设置为对应的元素了。 还增加了简单的元素添加及删除功能。 希望对初学者有用


