Ok, i have a List
in which i want to add some data from an Xlm file. My List
looks like that :
List<Tuple<string,string,string>> BookList;
And my Xml file looks like this :
<Book>
<Name>BookName</Name>
<Genre>BookGenre</Genre>
<Year>BookYear</Year>
</Book>
What i want is to read from the xml file, and every time i read a XmlNodeType.Text
add it inside the list. But how can i add lets say when i find the first XmlNodeType.Text
in the fisrt string, then when i read the second XmlNodeType.Text
in the second string of the list ....
What im doing now is this :
int count = 0;
string name,genre,year;
while (reader.Read())
{
if (count.Equals(3))
{
BookList.Add(Tuple.Create(name,genre,year));
count = 0;
}//if
switch (reader.NodeType)
{
case XmlNodeType.Text:
switch (count)
{
case 0:
name = reader.Value;
count++;
break;
case 1:
genre = reader.Value;
count++;
break;
case 2:
year = reader.Value;
count++;
break;
}//switch
break;
}//switch
}//while
Is there anyway to avoid using this ugly switch(count)
?