[英]c# XML read value
誰能告訴我如何從xml文檔中讀取值500?
XmlDocument xmldoc = new XmlDocument();
xmldoc.LoadXml ("<move action='bet' value='500' />");
嘗試以下操作。
string xmlAttributeValue = xmldoc.ChildNodes[0].Attributes["value"].Value
這也可以工作:
//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;
你可以試試這個
string attVal = xmldoc.GetElementsByTagName("move")[0].Attributes["value"].Value
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.