我想获取属性(备忘录)在xml文件中使用c#的值,我也想在文本框中显示值(美好的一天)。可以有人帮忙吗?阅读xml文件,并检索xml节点值使用c#
<tree>
<Product comment=" C# " memo="Wonderful day" />
</tree>
我想获取属性(备忘录)在xml文件中使用c#的值,我也想在文本框中显示值(美好的一天)。可以有人帮忙吗?阅读xml文件,并检索xml节点值使用c#
<tree>
<Product comment=" C# " memo="Wonderful day" />
</tree>
var [email protected]"<tree>
<Product comment="" C# "" memo=""Wonderful day"" />
</tree>";
var doc = XDocument.Parse(xml);
var memo = doc.Document.Descendants("Product").Single().Attribute("memo").Value;
输出:Wonderful day
看看XPath
可能重复(http://stackoverflow.com/questions/653092/how-to-retrieve-xml-node-attributes-in-c) –
我会检查:) – Karthik