我想獲取屬性(備忘錄)在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