开发者

c# XML read value

Can anyone tell me how to read the value 500 from the xml document, please?

XmlDocument xmldoc = new XmlDocum开发者_JAVA技巧ent(); 

xmldoc.LoadXml ("<move action='bet' value='500' />");


try something like following.

string xmlAttributeValue = xmldoc.ChildNodes[0].Attributes["value"].Value


You could get try this

string attVal = xmldoc.GetElementsByTagName("move")[0].Attributes["value"].Value


This could work too:

//Select the node with action='bet'
XmlNode node = xmldoc.SelectSingleNode("/move[@action='bet']");
// Read the value of the Attribute 'value'
var value = node.Attributes["value"].Value;


LINQ to XML http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜