给一段代码你看看:
System.Xml.XmlDocument parse=new XmlDocument();
try
{
parse.Load(XmlPath);
System.Xml.XmlElement root=parse.DocumentElement;
XmlNode xn=root.SelectSingleNode("//provider");
str="Provider=";
str=str+xn.InnerText;
xn=root.SelectSingleNode("//datasource");
str=str+"; Data Source=";
str=str+xn.InnerText;
XmlNode ini=root.SelectSingleNode("//initial");
XmlNode uid=root.SelectSingleNode("//uid");
XmlNode pwd=root.SelectSingleNode("//pwd");
XmlNode timeout=root.SelectSingleNode("//timeout");
if ((ini!=null)&&(ini.InnerText!="")) str=str+";"+"initial catalog="+ini.InnerText;
str=str+";"+"User ID="+uid.InnerText+" ; Password="+pwd.InnerText;
if ((ini!=null)&&(timeout.InnerText!="")) str=str+"; Connection Timeout="+timeout.InnerText;
}
System.Xml.XmlDocument parse=new XmlDocument();
try
{
parse.Load(XmlPath);
System.Xml.XmlElement root=parse.DocumentElement;
XmlNode xn=root.SelectSingleNode("//provider");
str="Provider=";
str=str+xn.InnerText;
xn=root.SelectSingleNode("//datasource");
str=str+"; Data Source=";
str=str+xn.InnerText;
XmlNode ini=root.SelectSingleNode("//initial");
XmlNode uid=root.SelectSingleNode("//uid");
XmlNode pwd=root.SelectSingleNode("//pwd");
XmlNode timeout=root.SelectSingleNode("//timeout");
if ((ini!=null)&&(ini.InnerText!="")) str=str+";"+"initial catalog="+ini.InnerText;
str=str+";"+"User ID="+uid.InnerText+" ; Password="+pwd.InnerText;
if ((ini!=null)&&(timeout.InnerText!="")) str=str+"; Connection Timeout="+timeout.InnerText;
}
解决方案 »
- .net remoting急求服务器和客户端交换信息
- ftp下载的图片可以直接显示pictureBox上吗
- 【正则表达式难题】[xxxx[yyyyy[zzzz]]] 匹配获得[]之间的字符串@
- 在线求助,给个C# 仿VS工具箱的例子
- 如何从Excel中把数据导入DataGridView中~~
- Cookie 中不能保存换行符?
- 高手请进:关于用WMI取远程PC内存的例子
- 有没有关于Visual Studio .net程序调试方面的文档资料
- 组件开发(急急急)
- 高分求救——我有几道C程序的编程题目,望各位高手帮忙解决!谢谢
- 初级问题,变量的使用范围
- 请问如何将写入的文件立刻写到硬盘,防止掉电时文件丢失呢?
while(xmlreaer.reader())
{
switch(xmlreader.nodetype)
{
case xmlnodeType.Element:
xmlReader.Name;
break;
case xmlNodeType.Text
xmlredder.value
break;
}
}
<?xml version="1.0" encoding="gb2312"?>
<Config>
<Database>
<Server>192.168.100.1</Server>
<Database>zhMis</Database>
<Uid>sa</Uid>
<Pwd>60FD7DD82EA95B91</Pwd>
</Database>
</Config>
using System.Xml;XmlDocument cmicXmlDoc=new XmlDocument();
cmicXmlDoc.Load(strFile);
XmlNode cmicNode;
cmicNode=cmicXmlDoc.SelectSingleNode(@"Config/Database/Server");
string tempServer=cmicNode.InnerText;cmicNode=cmicXmlDoc.SelectSingleNode(@"Config/Database/Database");
tempDatabase=cmicNode.InnerText; cmicNode=cmicXmlDoc.SelectSingleNode(@"Config/Database/Uid");
tempUid=cmicNode.InnerText; cmicNode=cmicXmlDoc.SelectSingleNode(@"Config/Database/Pwd");
tempPwd=cmicNode.InnerText;