用于 ASP.NET 应用程序的二进制文件中的 XML 数据还是直接 XML 文件?
我们需要将一些配置项保存到文件中。我被告知这是为了我们将要使用的一些本地化功能。据我所知,读取二进制文件比直接读取 XML 文件要快得多。这是真的吗?以二进制格式保存 xml 数据是否理想,或者是否有其他方法可以保存数据以将其拉入我的 Web 应用程序?
我希望能够使用 LINQ 读取数据或将其转换为对象。另外,解析文件中特定数据的最佳方法是什么?任何建议将不胜感激?
We have a need to save some of our configuration items into files. I have been told this is for some localization features we are going to use. From what I have been told, it is much faster to read from a binary file than a straight XML file. Is this true, and is it ideal to save xml data in binary format or is there another way I should save the data to pull it into my web application?
I would like to be able to read the data using LINQ or casting it as an object. Also, what is the best way to parse the file for sepecific data? Any suggestions would be greatly appreciated?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 XML 而不是二进制,只是因为它更容易使用。二进制速度更快,但我怀疑您会注意到应用程序中的速度增益,特别是如果您缓存从文件中读取的值。
解析 XML 文件的最简单方法是使用 XmlSerializer 类将其反序列化为对象。在我看来,这绝对是解析 XML 的最轻松的方法。
I would recommend using XML over binary simply because it's easier to work with. Binary is faster but I doubt you would notice that speed gain in your application, especially if you cache the values you read from the file.
The easiest way to parse the XML file would be to deserialize it to an object using the XmlSerializer class. This is absolutely the most painless way to parse XML in my opinion.