XML创建新结点
private void CreateNewXmlNode()
{
String strFileName = string.Empty;
strFileName = this.strCurrentPath + "System.xml";
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(strFileName);
XmlNode root = xmlDoc.SelectSingleNode("connect");
XmlElement xe1 = xmlDoc.CreateElement("Data2");
XmlElement xesub1 = xmlDoc.CreateElement("ServerType");
xesub1.InnerText = "SQLSERVER";
xe1.AppendChild(xesub1);
xesub1 = xmlDoc.CreateElement("Server");
xesub1.InnerText = "192.168.0.150";
xe1.AppendChild(xesub1);
xesub1 = xmlDoc.CreateElement("database");
xesub1.InnerText = "VirDinnerOfflineDB";
xe1.AppendChild(xesub1);
xesub1 = xmlDoc.CreateElement("UserID");
xesub1.InnerText = "sa";
xe1.AppendChild(xesub1);
xesub1 = xmlDoc.CreateElement("Password");
xesub1.InnerText = "1234";
xe1.AppendChild(xesub1);
root.AppendChild(xe1);
xmlDoc.Save(strFileName);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
}
相关文档:
String userId = request.getParameter("userId");
System.out.println(userId);
response.setCharacterEncoding("UTF-8");
//response.getWriter().println("hello world -- 我爱你。。。");
String xml = "<user>" +
"<username>涛哥</username>" +
"</user>";
respon ......
读XML文件
DataSet books = new DataSet();
books.ReadXml(MapPath("booklist.xml"));
booklist.DataSource = books;
booklist.DataBind(); ......
一、简单介绍
using System.Xml;
//初始化一个xml实例
XmlDocument xml=new XmlDocument();
//导入指定xml文件
xml.Load(path);
xml.Load(HttpContext.Current.Server.MapPath("~/file/bookstore.xml"));
//指定一个节点
XmlNode root=xml.SelectSingleNode("/root");
//获取节点下所有直接子节点
XmlNodeList ......
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"E:\大二下\xml\province.xml");
会提示出现以下错误
http://hi.csdn.net/attachment/201005/24/0_1274703276Ld6I.gif
麻烦各位帮忙看看,谢谢了 ......
Xml文件操作和文件操作(FileInfo类)
1. 上传文件
2. 写Xml文件
3. 文件拷贝
1. //上传
protected void picUp_Click(object sender, EventArgs e)
{
......