XmlDocument doc = new XmlDocument();
doc.LoadXml(
"<configuration>" + "<appSettings> " +
"<add key='title' value ='整合平台-解析工具'/>" +
"</appSettings>" + "</configuration>"); XmlNodeList node = doc.SelectNodes("//configuration/appSettings");
XmlNode elem = node[0]; Note that InnerText does not include the up.
Console.WriteLine("Display the InnerText of the element...");
Console.WriteLine(elem.Attributes["key"].InnerText); InnerXml includes the up of the element.
Console.WriteLine("Display the InnerXml of the element...");
Console.WriteLine(elem.InnerXml); Set InnerText to a string that includes up.
The up is escaped.
elem.InnerText = "Text containing <up/> will have char(<) and char(>) escaped.";
Console.WriteLine(elem.OuterXml); Set InnerXml to a string that includes up.
The up is not escaped.
elem.InnerXml = "Text containing <up/>.";
Console.WriteLine(elem.OuterXml);报错了,为什么?为什么获取不到属性值?
doc.LoadXml(
"<configuration>" + "<appSettings> " +
"<add key='title' value ='整合平台-解析工具'/>" +
"</appSettings>" + "</configuration>"); XmlNodeList node = doc.SelectNodes("//configuration/appSettings");
XmlNode elem = node[0]; Note that InnerText does not include the up.
Console.WriteLine("Display the InnerText of the element...");
Console.WriteLine(elem.Attributes["key"].InnerText); InnerXml includes the up of the element.
Console.WriteLine("Display the InnerXml of the element...");
Console.WriteLine(elem.InnerXml); Set InnerText to a string that includes up.
The up is escaped.
elem.InnerText = "Text containing <up/> will have char(<) and char(>) escaped.";
Console.WriteLine(elem.OuterXml); Set InnerXml to a string that includes up.
The up is not escaped.
elem.InnerXml = "Text containing <up/>.";
Console.WriteLine(elem.OuterXml);报错了,为什么?为什么获取不到属性值?
解决方案 »
- 怎样获得dataGridView控件的当前排序?
- datagridview赋值
- ComboBox根据输入内容自动填充
- 请教一个SQL查询问题:如何在同一条语句中,将前一条件查询的结果用于后一条件表达式?内详。
- System.DirectoryServices FindOne()调用失败问题?
- 奇怪的问题:一段代码在一个窗体可以运行,在另一个窗体却不行。。。
- C#只中使用ComboBox的问题
- 如何使用management上传、下载文件?在局域网中如何实现上传、下载文件?
- 如何获得命令行运行程序的窗口句柄(不从执行路径)
- c#的运行环境是不是一定要.net框架的支持?
- visitor模式
- 谁有自己做的播放器,不是哪种调用系统的,是通过MCI等自己解码做好的播放器!!!
xmldocument.Load("");
foreach(XmlNode node in xmldocument.SelectSingleNode("appSettings").ChildNodes)
{
if (node.Name == "add")
{
if (node.Attributes.GetNamedItem("key").Value == "")
{
}
}
}