I have to parse 80 GB OF XML to get some data from that file. I have used XML reader for this purpose. When I checked the code with 304 MB File. Then it parse the file within 4 sec. So I thought I will work for 80 GB. But it is giving me the memory out of exception after some minute.
I have the following code:
static void Main(string[] args)
    {
        List<Test> lstTest = new List<Test>();
        bool isTitle = false;
        bool isText = false;
        using (XmlReader Reader = XmlReader.Create(FilePath))
        {
            Test tt = new Test();
            while (Reader.Read())
            {                    switch (Reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (Reader.Name == "title")
                        {
                            isTitle = true;
                        }
                        if (Reader.Name == "text")
                        {
                            isText = true;
                        }
                        break;
                    case XmlNodeType.Text:
                        if (isTitle)
                        {
                            tt.Title = Reader.Value;
                            isTitle = false;
                        }
                        if (isText)
                        {
                            tt.Text = Reader.Value;
                            isText = false;
                        }
                        break;
                }
                if (tt.Text != null)
                {
                    lstTest.Add(tt);
                    tt = new Test();
                }
            }
        }
    }
}
}
So Please suggest. Thanks For your help.
 
     
     
     
    