如何读取大型xml文件而不将其加载到内存中并使用XElement [英] How to read large xml file without loading it in memory and using XElement
本文介绍了如何读取大型xml文件而不将其加载到内存中并使用XElement的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想读取一个较大的xml文件(100 + M).由于其大小,我不想使用XElement将其加载到内存中.我正在使用linq-xml查询来解析和读取它.
I want to read a large xml file (100+M). Due to its size, I do not want to load it in memory using XElement. I am using linq-xml queries to parse and read it.
最好的方法是什么? XPath或XmlReader与linq-xml/XElement结合的任何示例吗?
What's the best way to do it? Any example on combination of XPath or XmlReader with linq-xml/XElement?
请帮助.谢谢.
推荐答案
Yes, you can combine XmlReader with the method XNode.ReadFrom, see the example in the documentation which uses C# to selectively process nodes found by the XmlReader as an XElement.
这篇关于如何读取大型xml文件而不将其加载到内存中并使用XElement的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文