I'm trying to get the value of attribute(memo) in an xml file using c#,also i want t开发者_Python百科o display the value(wonderful day) in a textbox .Can anyone help?
<tree>
<Product comment=" C# " memo="Wonderful day" />
</tree>
Take a look at XPath
var xml=@"<tree>
<Product comment="" C# "" memo=""Wonderful day"" />
</tree>";
var doc = XDocument.Parse(xml);
var memo = doc.Document.Descendants("Product").Single().Attribute("memo").Value;
Output: Wonderful day
精彩评论