Q:
问:
How to get the attribute value of the root element(first element in my xml file) through LINQ.
如何通过LINQ获取根元素的属性值(我的xml文件中的第一个元素)。
.cs :
XDocument xmlDoc = XDocument.Load(targetFileName);
.xml :
<timetable ascttversion="2010" options="idprefix:realID">
I want to read the options
value.
我想阅读选项值。
2 个解决方案
#1
6
Something like this:
像这样的东西:
XDocument xdoc = XDocument.Load(targetFileName);
var attrib = xdoc.Root.Attribute("options").Value;
// attrib = "idprefix:realID"
#2
0
Following should do
以下应该做
xmlDoc.Root.Attribute("option").Value
#1
6
Something like this:
像这样的东西:
XDocument xdoc = XDocument.Load(targetFileName);
var attrib = xdoc.Root.Attribute("options").Value;
// attrib = "idprefix:realID"
#2
0
Following should do
以下应该做
xmlDoc.Root.Attribute("option").Value