开发者

How to use DataTable ReadXml to read small subsets of a large Xml file

开发者 https://www.devze.com 2023-02-01 12:04 出处:网络
I have an datatable serialized to Xml. It has 1000\'s of records. Using the DataTable\'s ReadXml method works, but it is very slow. I am only interested in the first 100 r开发者_StackOverflow社区ecord

I have an datatable serialized to Xml. It has 1000's of records. Using the DataTable's ReadXml method works, but it is very slow. I am only interested in the first 100 r开发者_StackOverflow社区ecords. Is there a way of reading the file, extracting the first 100 records, and loading that using the ReadXml method?


try something like this!

XmlDocument doc = new XmlDocument();
doc.Load( "c:\\testfile2.xml" );
foreach (XmlNode nd in doc.DocumentElement.SelectNodes( "xml/entry" ))
{
...
} 

im not up on dot net so this could be different..

also please look at this link http://msdn.microsoft.com/en-us/library/ms998559.aspx


I believe you can use one of the classes derived from System.Xml.XmlReader to sequentially read the file rather than loading the entire file into memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消