Reading integer from an xml file
-
I am sending game score to the web service and saving it there to xml file by using the following code: XmlTextWriter myWriter = new XmlTextWriter("highScores.xml", null); myWriter.WriteStartDocument(); myWriter.WriteStartElement("highestScore"); myWriter.WriteValue(score); myWriter.WriteEndElement(); myWriter.WriteEndDocument(); myWriter.Close(); I want to add to this function a condition to save the score only if it's higher than the score which already is in the xml. I was also trying to make another function to get this highest score from the xml, and return it to the Client. My problem is that I have no idea how to get this int (as an int) from the xml, I've tried few times on different ways bu still have no idea how to do this. Please help.
-
I am sending game score to the web service and saving it there to xml file by using the following code: XmlTextWriter myWriter = new XmlTextWriter("highScores.xml", null); myWriter.WriteStartDocument(); myWriter.WriteStartElement("highestScore"); myWriter.WriteValue(score); myWriter.WriteEndElement(); myWriter.WriteEndDocument(); myWriter.Close(); I want to add to this function a condition to save the score only if it's higher than the score which already is in the xml. I was also trying to make another function to get this highest score from the xml, and return it to the Client. My problem is that I have no idea how to get this int (as an int) from the xml, I've tried few times on different ways bu still have no idea how to do this. Please help.
-
I am sending game score to the web service and saving it there to xml file by using the following code: XmlTextWriter myWriter = new XmlTextWriter("highScores.xml", null); myWriter.WriteStartDocument(); myWriter.WriteStartElement("highestScore"); myWriter.WriteValue(score); myWriter.WriteEndElement(); myWriter.WriteEndDocument(); myWriter.Close(); I want to add to this function a condition to save the score only if it's higher than the score which already is in the xml. I was also trying to make another function to get this highest score from the xml, and return it to the Client. My problem is that I have no idea how to get this int (as an int) from the xml, I've tried few times on different ways bu still have no idea how to do this. Please help.
You should be clearer in what you are trying to say. 0) Shouldn't you already know whether or not the score is the high score? 1) Why not store the date and time as well as the score?
-
when you read a value from xml you get a string. to convert it to int use int.TryParse method.
life is study!!!