<?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节点的属性吗?
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;