在C#中解析大型XML(大小为1GB)的最佳方法是什么? [英] What is the best way to parse large XML (size of 1GB) in C#?

查看:98
本文介绍了在C#中解析大型XML(大小为1GB)的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个1GB的XML文件,想解析它.如果我使用XML Textreader或XMLDocument,则结果非常缓慢,有时会挂起...

I have a 1GB XML file and want to parse it. If I use XML Textreader or XMLDocument, the result is very slow and some times it hangs...

推荐答案

您将不得不使用xmlreader实现自定义逻辑. xmlreader不会在使用前将完整的XML加载到内存中,这意味着您可以从流中读取它并进行相应的处理.

You'll have to implement custom logic using xmlreader. xmlreader does not load the full XML into memory before using it, which means you can read it from a stream and process it as such.

这篇关于在C#中解析大型XML(大小为1GB)的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆