[英]How to get the xml attribute value of root?
Q: 问:
How to get the attribute value of the root element(first element in my xml file) through LINQ. 如何通过LINQ获取根元素的属性值(我的xml文件中的第一个元素)。
XDocument xmlDoc = XDocument.Load(targetFileName);
<timetable ascttversion="2010" options="idprefix:realID">
I want to read the options
value. 我想阅读
options
值。
Something like this: 像这样的东西:
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.