var q = from n in XElement.Load(Application.StartupPath + "..\\..\\..\\2.xml").Elements()
select n;
foreach (var q0 in q)
{
string str = q0.ToString();
}
the problem is my xml file is so big so how I can manage this code to load it gradually not completely. now I traced by c# it loads all file completely in “q” and then loads some big nodes in “str”. I have limited memory and I need loading from file a little by little. I dont know how many nodes I have but I know general structure of file.
Instead of reading the whole XML file in memory at once and then iterating over it, check out the XmlReader class and its derivatives. These allow you to traverse your XML node per node.
XmlTextReader is a particular derivative for reading XML from text files.
Check out http://support.microsoft.com/kb/307548.