XML 序列化程序错误需要帮助
这是我的代码
// Read the data from the file
XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
data = (HighScoreData)serializer.Deserialize(stream);
,我目前正在为我的游戏保存高分。但出现错误“xml 文档 (0, 0) 中存在错误。 愿意提供帮助或启发吗?
here is my code
// Read the data from the file
XmlSerializer serializer = new XmlSerializer(typeof(HighScoreData));
data = (HighScoreData)serializer.Deserialize(stream);
im currently doing a saving highscore for my game. but it get an error of "there is an error in xml document (0, 0).
care to help or enlighten?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前遇到过这个问题,文件开头有一个字节顺序标记。在十六进制编辑器中检查 XML 文件,看看开头是否有三个字符。您可以简单地使用原始 xml 执行类似以下操作
,然后将其读入流中
,或者您可以在创建流时执行类似的操作,
希望这会有所帮助
i have had this problem before and a byte order mark was present at the beginning of the file. Check your XML file in a hex editor and see if there are three characters at the beginning. You could simply do something like the following with your raw xml
then read that into the stream
or you could do something like this when creating your stream
hopefully that helps