像这样从xml文件更新和删除 [英] update and delete from xml file like this

查看:156
本文介绍了像这样从xml文件更新和删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

我有这个xml文件:

hi all :)

I have this xml file :

<folio>
  <site>
    <description>Stairs 01</description>
    <thumbnail>./images/adrajs01.jpg</thumbnail>
    <pic>./images/adraj01.jpg</pic>
    <imageWidth>700</imageWidth>
    <imageHeight>525</imageHeight>
    <categoryid>1</categoryid>
  </site>
  <site>
    <description>Stairs 02</description>
    <thumbnail>./images/adrajs02.jpg</thumbnail>
    <pic>./images/adraj02.jpg</pic>
    <imageWidth>700</imageWidth>
    <imageHeight>525</imageHeight>
    <categoryid>1</categoryid>
  </site>
</folio>



在路径="some/folders/g.xml"

我想根据描述"值从该文件中更新和删除

我读了很多文章,但没有人与我合作

我使用ASP.Net,C#

谢谢大家:)



at path = "some/folders/g.xml"

I want to update and delete from this file according to "description" value

I read a lot of articles but no one worked with me

I use ASP.Net, C#

thank you all :)

推荐答案

我想根据描述"值从该文件中更新和删除

我读了很多文章,但没有人与我合作

我使用ASP.Net,C#

而且您正在危险的水域中行走.只要您只是阅读和xml文件-事情就很简单-但是如果应用程序池在写入xml文件的过程中被终止,该怎么办?对于完全超出您控制范围的原因 [模式 [ ^ ],然后通过
I want to update and delete from this file according to "description" value

I read a lot of articles but no one worked with me

I use ASP.Net, C#

And you are treading in dangerous waters. As long as you are just reading and xml file - things are pretty simple - but what will you do if the app pool is terminated in the middle of a write to the xml file? This can and does happen for reasons that are entirely beyond your control[^] in asp.net. At least make sure that you always make a backup of the original file before writing out the new data.

Create a schema[^] for the xml file, and run it through the xsd[^] code generation tool.

The resulting library is quite easy to work with.

Best regards
Espen Harlinn


本质上,从XML中删除节点就是读取和解析XML,从数据中删除节点并再次写入相同的文件.仔细考虑Espen给您的警告.
最简单的方法是使用DOM和类System.Xml.XmlDocument,请参见
http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx [
Essentially, removing a node from XML is reading and parsing XML, removing a node from data and writing the same file again. Thoroughly consider the warnings Espen gave you.
The easiest way of doing this is using DOM and the class System.Xml.XmlDocument, see http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^].

—SA


这篇关于像这样从xml文件更新和删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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