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;
}
}
相关文档:
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 ......
xsd与xml和类(class)对象之间的互相转换
.
第一:通过现有的已经写好的xsd来生成class(.cs)文件。
在您Visual Studio的安装目录下的SDKv2.0Bin中有个应用程序xsd.exe(通过这个应用程序可以使用xsd来创建类文件)。
具体操作:通过打开Visual Studio 命令提示,可以输入xsd指令来查看一些具体的操作指令的用处,然后 ......