Your XML basically consists of a sequence <LIST> of lists list="1 2 3" of integers. You have a couple options to parse this XML and extract a List<int> list for each <LIST> element.
Firstly, You can use XmlSerializer to deserialize your XML. First define the followng data model:
[XmlRoot("LISTS")]
public class ListRoot
{
[XmlElement("LIST")]
public List<ListEntry> Lists { get; set; } = new List<ListEntry>();
}
public class ListEntry
{
[XmlAttribute("list")]
public List<int> ListItems { get; set; } = new List<int>();
}
Then you can deserialize from a file located at fileName as follows:
ListRoot listRoot;
var serializer = new XmlSerializer(typeof(ListRoot));
using (var stream = File.OpenRead(fileName))
listRoot = (ListRoot)serializer.Deserialize(stream);
By marking the List<int> ListItems with [XmlAttribute("list")], XmlSerializer will automatically deserialize the space-delimited list="2 4 ..." attributes into the inner ListItems list.
Now you can access the list items as follows:
foreach (var entry in listRoot.Lists)
{
List<int> list = entry.ListItems; // The contents of each list="1 2 ..." /> attribute materialized as a List<int>
// Process the List<int> list however you want:
Console.WriteLine(string.Join(",", list));
}
Which outputs:
213,82,14,2,3,4,18,4,1,5,5,3,6,5,2
2,4,5,1,4,0,0,0,2,3,5,532,7,10,0
10,511,4,8,2,6,4,721,2,5,7,10,10,4
Demo fiddle #1 here.
Alternatively, you could use LINQ to XML to load your XML into an XDocument and query it using LINQ:
var listRoot = XDocument.Load(fileName);
var listItems = listRoot.Root
.Elements("LIST") // Select the <LIST> child nodes
.Select(e => e.Attribute("list")) // Select the list=".." attribute
.Select(a => a.Value.Split(' ').Select(s => XmlConvert.ToInt32(s)).ToList()) // Convert the space-delimited integer string to a list of integers
.ToList(); // And materialize the query
foreach (List<int> list in listItems)
{
// Process the List<int> list however you want:
Console.WriteLine(string.Join(",", list));
}
Demo fiddle #2 here.
I don't really recommend using the older XmlDocument for new code as LINQ to XML is easier to use and more performant.