簡體   English   中英

如何獲取root的xml屬性值?

[英]How to get the xml attribute value of root?

問:

如何通過LINQ獲取根元素的屬性值(我的xml文件中的第一個元素)。

.cs:

 XDocument xmlDoc = XDocument.Load(targetFileName);

.xml:

<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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM