<?xml version="1.0" encoding="utf-8"?>
  <configurations>
    <Time1>"2013/7/12 上午 09:28:48"</Time1>
    <Time2>"2013/7/13 上午 09:28:48"</Time2>
    <Time3>"2013/7/14 上午 09:28:48"</Time3>
  </configurations>
 以上是配置文件(文件名為Config.xml),自己剛學的不知道對不對;
請問如何遍曆配置文件中的參數獲取time1,time2,time3的值。

解决方案 »

  1.   

    参考:
    XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load("test.xml");            XmlNode xmlNode = xmlDocument.SelectSingleNode("configurations/Time1");
                string value = xmlNode.InnerText;
      

  2.   

    Linq to xml:
    XElement root = XElement.Load("test.xml");
                IEnumerable address = from el in root.Elements()
                                      select el;            foreach (XElement el in address)
                {
                    Console.WriteLine(el.Value);
                }
      

  3.   


    这是linq的写法,需要.net framework 3.5的支持。你用第一种方法好了。