Hello everyone. I tried to write a simple xml reader, but found that it inadvertently skips all the other elements in the XML file.
I guess I tell him to move on to the next element twice, but I'm not sure what is happening or what the decision is.
any help would be greatly appreciated :)
Here is sample code and sample xml file
public LevelLoader(string theLevelFile ,ContentManager theContent)
{
XmlTextReader reader = new XmlTextReader(theLevelFile);
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
switch (reader.Name)
{
case "tilerow":
{
currentRow = currentRow + 1;
Console.WriteLine("row found");
currentCol = 0;
break;
}
case "tilecol":
{
Console.WriteLine("col found");
currentTexture = reader.ReadElementContentAsFloat();
currentCol = currentCol + 1;
break;
}
}
}
}
}
xml sample
<tilerow>
<tilecol>1</tilecol><tilecol>2</tilecol><tilecol>3</tilecol><tilecol>4</tilecol><tilecol>5</tilecol><tilecol>6</tilecol><tilecol>7</tilecol><tilecol>8</tilecol><tilecol>9</tilecol><tilecol>10</tilecol>
</tilerow>
source
share