private SimpleEntity CheckNodes(XmlTextReader xml)
        {
            if (xml.NodeType == XmlNodeType.Element && xml.IsStartElement())
            {
                Flags.LastNode = xml.LocalName;
            }

            if (xml.NodeType == XmlNodeType.Text)
            {
                var v = new SimpleEntity()
                {
                    Property = Flags.LastNode,
                    Value    = xml.Value
                };

                return(v);
            }

            return(null);
        }
        private void WriteExcel(SimpleEntity entity)
        {
            Application xlApp = new Application();

            if (xlApp == null)
            {
                Log("Excel is not properly installed!!");
                return;
            }

            xlApp.DisplayAlerts = false;

            Workbook  xlWorkBook;
            Worksheet xlWorkSheet;
            object    misValue = System.Reflection.Missing.Value;

            var currentDir       = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var completeFilename = currentDir + "\\sample2.xls";

            if (IsBeginOfFile())
            {
                xlWorkBook  = xlApp.Workbooks.Add(misValue);
                xlWorkSheet = (Worksheet)xlWorkBook.Worksheets[1];

                if (File.Exists(completeFilename))
                {
                    File.Delete(completeFilename);
                }
            }
            else
            {
                if (File.Exists(completeFilename))
                {
                    xlWorkBook  = xlApp.Workbooks.Open(completeFilename);
                    xlWorkSheet = xlWorkBook.Worksheets[1];
                }
                else
                {
                    xlWorkBook  = xlApp.Workbooks.Add(misValue);
                    xlWorkSheet = (Worksheet)xlWorkBook.Worksheets[1];
                }
            }

            if (entity.Property.ToLower() == xlWorkSheet.Cells[1, 1].Text.ToLower())
            {
                Flags.rowCount++;
                Flags.columnCount = 1;
            }

            xlWorkSheet.Cells[1, Flags.columnCount] = entity.Property;
            xlWorkSheet.Cells[Flags.rowCount, Flags.columnCount] = entity.Value;

            Flags.columnCount++;

            xlWorkBook.SaveAs(completeFilename);

            xlWorkBook.Close(true);
            xlApp.Quit();

            Marshal.ReleaseComObject(xlWorkSheet);
            Marshal.ReleaseComObject(xlWorkBook);
            Marshal.ReleaseComObject(xlApp);

            Log("Excel file created , you can find the file sample2.xls");
        }