如何使用DOM删除Xml的结束标记 [英] How to remove closing tag of Xml using DOM

查看:71
本文介绍了如何使用DOM删除Xml的结束标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我想使用dom删除xml的结束标记。如何删除结束标记?



例如,



< pre lang =xml>< tittle> 
< name> xxxx< / name>
< / tittle>



在上面的示例中,我需要删除

< / tittle> 

解决方案

如果您使用的是XML DOM Document模型,那么您不应该(也不能)删除结束标记。



正如Ron Beyer所说 - 只需将您需要的值添加到相应的节点(可以是根节点)



这里有一些链接可以进一步演示.. 。

http://msdn.microsoft.com/en-us/library /aa468547.aspx [ ^ ]



http://www.w3schools.com/dom/ [ ^ ]



另一种选择是XMLWriter类



http://www.dotnetperls.com/xmlwriter [ ^

Dear Friends,

I want to remove the closing tag of xml using dom.How to remove the closing tag ?

For Eg,

<pre lang="xml"><tittle>
        <name>xxxx</name>
  </tittle>


In the above example i need to remove

</tittle>

解决方案

If you are using the XML DOM Document model then you should not (and cannot) remove the closing tag.

As Ron Beyer has said - just add the values you require to the appropriate node (which can be the root)

Here are some links to demonstrate further...
http://msdn.microsoft.com/en-us/library/aa468547.aspx[^]

http://www.w3schools.com/dom/[^]

An alternative is the XMLWriter class

http://www.dotnetperls.com/xmlwriter[^]


这篇关于如何使用DOM删除Xml的结束标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆