Here is one way how to implement it.
c#
void Main()
{
const string SOURCEXMLFILE = @"e:\Temp\MarkusFreitagInput.xml";
XDocument xdoc = XDocument.Load(SOURCEXMLFILE);
List<PositionObject> objects2 = new List<PositionObject>();
objects2 = xdoc.Descendants("POSITION")
.Select(p => new PositionObject()
{
Index = Convert.ToInt16(p.Element("INDEX").Attribute("value")?.Value),
YPOS = p.Element("YPOS").Attribute("value")?.Value
}
).ToList();
}
public class PositionObject
{
public int Index { get; set; }
public string YPOS { get; set; }
}
-- UPDATE --
Method #2, by using a dictionary.
void Main()
{
const string SOURCEXMLFILE = @"e:\Temp\MarkusFreitagInput.xml";
XDocument xdoc = XDocument.Load(SOURCEXMLFILE);
Dictionary<int, string> dictIndexContent = new Dictionary<int, string>();
dictIndexContent = xdoc.Descendants("POSITION")
.ToDictionary(e => Convert.ToInt32(e.Element("INDEX").Attribute("value")?.Value),
e => e.Element("YPOS").Attribute("value")?.Value);
}