Game Development Reference
In-Depth Information
//Using doc.Load("HiScore.xml"); When load from
an xml file
//Using Last Child to Skip the <?xml
version="1.0" encoding="UTF-8"?>
//If we load from the xml file we will use the
FirstChild instead
_root = _doc.LastChild;
if (_root.HasChildNodes ) {
_usersLength = _root.ChildNodes.Count;
_users = new UserData[_usersLength];
for (int i = 0; i < _usersLength; i++) {
if
(_root.ChildNodes[i].InnerText.Contains("No entries
yet.") == false) {
XmlAttribute nameAtt =
_root.ChildNodes[i].Attributes["name"];
XmlAttribute scoreAtt =
_root.ChildNodes[i].Attributes["score"];
UserData user = new UserData();
user.name = nameAtt.Value;
user.score =
Convert.ToInt32(scoreAtt.Value);
_users[i] = user;
} else {
break;
}
}
}
}
}
Search WWH ::




Custom Search