Convert XML attributes to a Dictionary in Linq to XML
- by NateD
I've got a program that needs to convert two attributes of a particular tag to the key and value of an Dictionary<int,string>. The XML looks like this:
(fragment)
<startingPoint coordinates="1,1" player="1" />
and so far my LINQ looks something like this:
XNamespace ns = "http://the_namespace";
var startingpoints = from sp in xml.Elements(ns+"startingPoint")
from el in sp.Attributes()
select el.Value;
Which gets me a nice IEnumerable full of things like "1,1" and "1", but there should be a way to adapt something like this answer to do attributes instead of elements. Little help please? Thank you!