使用 XmlReader 连接 xml 文件
我通过 id 使用 LINQ to XML 连接 3 个 xml 日志文件,但是当我的日志文件变得太大时,LINQ to XML 不再工作,所以我必须使用 XmlReader。
但现在我问自己该怎么做?
我应该循环遍历每个 id 的每个文档,还是有更简单优雅的解决方案?
有人吗?
I am joining 3 xml logfiles with LINQ to XML by id, but when my logfiles become too big, LINQ to XML doesn't work anymore, so i have to use XmlReader.
But now I am asking myself how to do this?
Should i loop through every document for each id, or is there a more simple elegant solution?
Anybody?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XMLReader 对一个文件具有亲和力。所以你一次只能处理一个文件。我想在你的场景中可以启动 3 个读取器并将文件加载到内存中。我在这里看到的一个可能的问题是如何有效地“加入”这 3 个文件。假设第一条记录中的第一个 id 位于第二条记录中间和第三条记录末尾的某个位置。为了找到它们,您必须重复遍历 xml。这没有道理。就我个人而言,我会尝试将信息加载到数据库中,将那里的文件作为表关联起来。作为数据库结构,您可以使用索引的所有功能来快速链接数据。
The XMLReader has an affinity for one file. So you can only process one file at a time. I suppose in your scenario its possible to fire up 3 readers and load the files into memory. A possible problem I see here is how you would efficiently "join" the 3 files. Say the first id in the first record is located somewhere in the middle of the second and at the end of the third. In order to find them you would have to repeatedly traverse the xml. That doesnt make sense. Personally I would try to load the information into a db in relate the files there -a s tables. As db structures you have all the power of indexing available to quickly link data.