XML reader is going to read through each element in the XML tree, so you just need to keep going if you haven't hit the nodes you want yet by putting the reader in a loop. You're code needs to continue to loop through the XML, so it would need to look a little more like this:
using (XmlReader reader = XmlReader.Create(filepath))
{
while(reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case "Candidate":
string name = reader["CandidateName"];
break;
case "Vote":
string voteStr = reader["VoteString"];
break;
}
}
}
}
Of course, the more important question here is what are you trying to do with those values you are getting? Your current code doesn't actually do anything with the values except assign them to a variable that goes out of scope immediately.