开发者

Read an xml file and retrieve xml node Value using c#

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜