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;
}
}
相关文档:
Product.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="product.css" ?>
<productata>
<product prodid="p001" category="toy">
<productname>Mini Bus</productname>
<description>This is a toy for childern aged 4 and above&l ......
ID.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="ID.css"?>
<bookdetail>
<book class="A" id="B1">
<author>曹雪芹</author>
<title>红楼梦</title>
<price>60.00</price>
</book>
<book class="A ......
xmlpost by HttpWebRequest:
protected string PostXmlToURL(string url,string data)
{
HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create(url);
hwr.Method = "POST";
Stream stream = hwr.GetRequestStream();
StreamWri ......
Xml文件操作和文件操作(FileInfo类)
1. 上传文件
2. 写Xml文件
3. 文件拷贝
1. //上传
protected void picUp_Click(object sender, EventArgs e)
{
......