Is there a class that supports XPath but don't load the whole document?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
Lets say I have a XML document which, under the root element <SalesRoot> contains 20 million <Sales> elements.
I am looking for a smart C# class, say called IdealXmlDocument , which supports XPath, but doesnt load the whole XML document into memory.

For example I want to be able to do following
<pre class="prettyprint IdealXmlDocument xdoc = new IdealXmlDocument("c:tempsales.xml");

foreach(IdealXmlNode xnode in xdoc.SelectNodes("/SalesRoot/Sales"))
{
// run future relevant XPath queries within this single <Sales> node
}[/code]
When the first xnode is requested, the IdealXmlDocument
reads in the first <Sales> element from the file stream. When the second
xnode is fetched, it advances to load the next <Sales>...
In other words, it only loads as much XML into memory as a single XPath query can be run, and never loads the whole 20 million <sales> elements into memory.
Will there be such a smart class somewhere?
<br/>


View the full article
 
Back
Top