Reputation: 318
I'm trying to get the value of attribute(memo) in an xml file using c#,also i want to display the value(wonderful day) in a textbox .Can anyone help?
<tree>
<Product comment=" C# " memo="Wonderful day" />
</tree>
Upvotes: 0
Views: 1535
Reputation: 56162
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
Upvotes: 1