日期:2014-05-18  浏览次数:20387 次

100分求一读取xml文件程序代码
100分求一读取xml文件程序代码

例如读取以下xml文件
<?xml   version= "1.0 "   encoding= "utf-8 "   ?>
<applicationdata>
          <information   titles= "1 "       contents= "dfsdfg "   > </information>
          <information   titles= "sdf "   contents= "df "   > </information>
          <information   titles= "asd "   contents= "sdf "   > </information>
          <information   titles= "sdf "   contents= "sdf "   > </information>
          <information   titles= "asd "   contents= "sf "   > </information>
</applicationdata>


实现对此文件的增加/删除/操作     和链接方法   谢谢
求详细代码  


------解决方案--------------------

网上搜 xml操作 C#
------解决方案--------------------
用XmlDocument来载入啊,用xmlReader和XmlWriter来读写
------解决方案--------------------
xml dom
------解决方案--------------------
up
------解决方案--------------------
找本书看看,关于XML的操作
------解决方案--------------------
(二). XML学习(Working with XML)

1.幻灯片课程

下载: http://www.cnblogs.com/Files/ChengKing/Working%20with%20XML(ppt).rar

2.示例代码

下载: http://www.cnblogs.com/Files/ChengKing/Working%20with%20XML(project).rar


http://blog.csdn.net/ChengKing/archive/2006/03/31/646363.aspx
------解决方案--------------------
这个你得学习,不要 【伸手就要代码来】

XML 文档对象模型 (DOM)
http://msdn2.microsoft.com/zh-cn/library/hf9hbf87(VS.80).aspx

XmlDocument 类
http://msdn2.microsoft.com/zh-cn/library/System.Xml.XmlDocument(VS.80).aspx

XmlNode.SelectSingleNode 方法
http://msdn2.microsoft.com/zh-cn/library/fb63z0tw(vs.80).aspx
------解决方案--------------------
private void del(string titles)
{
doc.Load( "e:\\new.xml ");
XmlNodeList nodeList = doc.SelectSingleNode( "applicationdata ").SelectNodes( "information ");
foreach (XmlNode node in nodeList)
{
if (node.Attributes[ "titles "].Value == titles)
{
doc.SelectSingleNode( "applicationdata ").RemoveChild(node);
}
}
doc.Save( "e:\\new.xml ");
}
private void inse(string titles, string contents)
{
doc.Load( "e:\\new.xml ");
XmlElement element = doc.CreateElement( "information ");
element.SetAttribute( "titles ", titles);
element.SetAttribute( "contents ", contents);
doc.SelectSingleNode( "applicationdata ").AppendChild(element);
doc.Save( "e:\\new.xml ");
}
------解决方案--------------------