C#读写xml文件的简单例子
发布时间:2016-06-13 编辑:jiaochengji.com
分享一个c#实现的读写xml配置文件的例子,学习下xmlDocument的用法,有需要的朋友参考下吧。
c#实现读取与写入xml配置文件。
代码:
复制代码 代码示例:
//读配置文件
XmlDocument doc = new XmlDocument();
doc.Load("blog.xml");
XmlNode url = doc.SelectSingleNode("博客/广告地址");
texturl.Text = url.InnerText;
XmlNode Name = doc.SelectSingleNode("博客/用户名1");
name = Name.InnerText;
XmlNode Password = doc.SelectSingleNode("博客/密码1");
password = Password.InnerText;
XmlNode dbid = doc.SelectSingleNode("博客/DBID");
DBID = int.Parse(dbid.InnerText);
//写配置文件
XmlDocument doc = new XmlDocument();
doc.Load("blog.xml");
XmlNode xiugai = doc.SelectSingleNode("博客");
xiugai["DBID"].InnerText = DBID.ToString(); //修改值
doc.Save("blog.xml");
XmlDocument doc = new XmlDocument();
doc.Load("blog.xml");
XmlNode url = doc.SelectSingleNode("博客/广告地址");
texturl.Text = url.InnerText;
XmlNode Name = doc.SelectSingleNode("博客/用户名1");
name = Name.InnerText;
XmlNode Password = doc.SelectSingleNode("博客/密码1");
password = Password.InnerText;
XmlNode dbid = doc.SelectSingleNode("博客/DBID");
DBID = int.Parse(dbid.InnerText);
//写配置文件
XmlDocument doc = new XmlDocument();
doc.Load("blog.xml");
XmlNode xiugai = doc.SelectSingleNode("博客");
xiugai["DBID"].InnerText = DBID.ToString(); //修改值
doc.Save("blog.xml");
您可能感兴趣的文章:
C#读写xml配置文件(LINQ操作实例)
C#读写xml文件的实例代码
asp.net读写xml文件的代码一例
您可能感兴趣的文章:
php操作xml文件的一些简单范例
C#读写xml文件的简单例子
asp.net读写xml文件的代码一例
C#读写xml配置文件(LINQ操作实例)
PHP读取XML的几种方法
C# 写入XML文档的三种方法与代码实例
php操作xml的各种方法解析
C#读写xml文件的实例代码
PHP读取XML值的代码
C# 生成XML文档的三种方法与代码实例
[关闭]