<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key ="hour" value="20"/>
    <add key="minute" value="00"/>
    <add key ="bSetFlag" value ="false"/>
  </appSettings>
    
</configuration>
这个xml配置文件怎么读取,修改?
我想获得appSettings节点的下3个value值,给予代码提示,谢谢!
三分key都是appSettings节点的属性吗?

解决方案 »

  1.   

    你这个是项目的配置文件么?还是你自定义的xml文件
      

  2.   

    方法一:LinqtoXml    
    XDocument doc = XDocument.Load("C://1.xml");
                XElement node = doc.Element("Navigation_Conf").Element("Navigation_1st").Elements("Navigation_2st").ToList().Find(m => m.Element("N2_Name").Value.Trim() == "语文");
                string s= node.Element("N2_Seq").Value;
                s+=node.Element("N2_Name").Value;
                s+=node.Element("Icon").Value;
                s+=node.Element("PBType").Value;
    方法2:XPath
    XmlDocument doc = new XmlDocument();
                doc.Load("C://1.xml");
                XmlNode node = doc.SelectSingleNode("//Navigation_2st[N2_Name='语文']");
                string s = node.SelectSingleNode("N2_Seq").InnerText;
                s += node.SelectSingleNode("N2_Name").InnerText;
                s += node.SelectSingleNode("Icon").InnerText;
                s += node.SelectSingleNode("PBType").InnerText;
      

  3.   

    http://www.cnblogs.com/malin/archive/2010/03/04/1678352.html  还看实例来着实在。