How to get xml attribute value for root?

AT:

How to get root element attribute value (first element in my xml file) via LINQ.

.cs:

 XDocument xmlDoc = XDocument.Load(targetFileName);

.xml:

<timetable ascttversion="2010"  options="idprefix:realID">

I want to read the meaning options.

+5
source share
2 answers

Something like that:

XDocument xdoc = XDocument.Load(targetFileName);
var attrib = xdoc.Root.Attribute("options").Value;

// attrib = "idprefix:realID"
+6
source

Following should do

xmlDoc.Root.Attribute("option").Value
0
source

All Articles