How to use DataTable ReadXml to read small subsets of a large Xml file
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.
精彩评论