How to properly parse this XML with C#?

phantom101

New Member
I have the following XML code:\[code\]<Presets> <Preset ID="0" Name="aaaa"> <IncludedChampions> <ID>5</ID> <ID>6</ID> <ID>7</ID> </IncludedChampions> </Preset> <Preset ID="1" Name="some"> <IncludedChampions> <ID>4</ID> <ID>5</ID> <ID>6</ID> </IncludedChampions> </Preset></Presets>\[/code\]and I'm trying to parse it with this:\[code\]XmlReader reader = XmlReader.Create("./config.xml");while (reader.Read()){ while (reader.ReadToFollowing("Preset")) { presetList.Add(new Preset()); presetList[presetList.Count - 1].name = reader.GetAttribute(1); Console.WriteLine("Preset list ID " + Convert.ToString(presetList.Count - 1)); while (reader.ReadToFollowing("ID")) { Console.WriteLine("Champion ID " + reader.ReadElementContentAsString()); } }}\[/code\]But in the output, I only see 'Preset list ID 0' and then all the ID's. Where did the other Preset ID go? Thanks!
 
Back
Top