I am searching the fastest way to count some tags in a huge xml-file (120MB)
long Quantity;
XPathDocument xDocData = new XPathDocument(str_File_path);
XPathNavigator xNavData = xDocData.CreateNavigator();
//Option 1
XPathExpression xExp = xNavData.Compile("sum(Tag/Value)");
Quantity = Convert.ToInt64(xNavData.Evaluate(xExp));
//Option 2
XPathNodeIterator xNodeIter = xNavData.Select(xExp);
while(xNodeIter.MoveNext())
{
Quantity += xNodeIter.Current.ValueAsLong;
}
Any suggestions?
greetings and thanks in advance
Are you only looking to get counts from this file, or do you actually need the contents for some other purpose? If you just need the counts, and the file is that large, it's probably more efficient to use a SAX Parser, catch the events on the relevant nodes, and increment on those events.