c#——自己用到的简单的xml操作

直接代码:

View Code
 #region 全局变量

string strXmlName = null;
string webURL = null;
string webName = null;
string listName = null;
string listCount = null;
string strTime = null;
int dtTime = 5000;


#endregion

#region 读取XML方法

private string ReadXml()
{
try
{
//读取xml文档
XmlDocument doc = new XmlDocument();
strXmlName = Application.StartupPath + @"\SPXML.xml";
doc.Load(strXmlName);

XmlNode node1 = doc.SelectSingleNode("/SPSite/SPSiteLink");
XmlNode node2 = doc.SelectSingleNode("/SPSite/SPWebName");
XmlNode node3 = doc.SelectSingleNode("/SPSite/SPListName");
XmlNode node4 = doc.SelectSingleNode("/SPSite/SPListCount");
XmlNode node5 = doc.SelectSingleNode("/SPSite/SPInterval");

//变量赋值
webURL = node1.InnerText;
webName = node2.InnerText;
listName = node3.InnerText;
listCount = node4.InnerText;
strTime = node5.InnerText;
dtTime = Convert.ToInt32(strTime);

return "";
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}

#endregion

 

posted @ 2012-02-24 16:20  mike_zhao  阅读(107)  评论(0)    收藏  举报