[英]How to get the xml attribute value of root?
問:
如何通過LINQ獲取根元素的屬性值(我的xml文件中的第一個元素)。
XDocument xmlDoc = XDocument.Load(targetFileName);
<timetable ascttversion="2010" options="idprefix:realID">
我想閱讀options
值。
像這樣的東西:
XDocument xdoc = XDocument.Load(targetFileName);
var attrib = xdoc.Root.Attribute("options").Value;
// attrib = "idprefix:realID"
以下應該做
xmlDoc.Root.Attribute("option").Value
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.