コード例 #1
0
        public void TestBigXml()
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            ReadXml r = new ReadXml
            {
                StringPath = @"C:\Users\dor\source\repos\xmlTest\XmlParser\test2.xml"
            };

            XmlParser parser = new AdvancedXmlParser
            {
                Document = r.ReadFile(),

                ParserConfig = new Config
                {
                    Paths = new List <string>(new string[] { "rows/head", "rows", "rows/head/property", "bla", "rows/row" }),
                }
            };

            parser.ParseData(LoggerType.DEBUG);
            sw.Stop();
            using (parser.Log = LoggerFactory.GetLogger(LoggerType.DEBUG))
            {
                parser.Log.LogMessage("Time total: " + sw.Elapsed);
            }
            Assert.IsTrue(sw.Elapsed.TotalSeconds < 1, String.Format("Took more than a second {0} for 1000 line XML, not good enough", sw.Elapsed));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: dolinar/XmlParser2
        private static Dictionary <string, List <Tag> > init()
        {
            ReadXml r = new ReadXml
            {
                StringPath = @"C:\Users\dor\source\repos\xmlTest\XmlParser\test2.xml"
            };

            XmlParser parser = new AdvancedXmlParser();

            try
            {
                parser.Document     = r.ReadFile();
                parser.ParserConfig = new Config
                {
                    Paths = new List <string>(new string[] { "rows/head", "rows/row" }),
                };

                parser.ParseData(LoggerType.DEBUG);
                return(parser.ParsedData);
            } catch (FileNotFoundException fnfException)
            {
                Console.WriteLine(fnfException.Message + " " + fnfException.FileName);
                Console.WriteLine("Click any key to exit the program");
                Console.ReadKey();
                Environment.Exit(1);
            } catch (XmlException xmlException)
            {
                Console.WriteLine(xmlException.Message);
                Console.WriteLine("Click any key to exit the program");
                Console.ReadKey();
                Environment.Exit(1);
            } catch (ArgumentNullException anException)
            {
                Console.WriteLine(anException.Message);
                Console.WriteLine("Click any key to exit the program");
                Console.ReadKey();
                Environment.Exit(1);
            } catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Click any key to exit the program");
                Console.ReadKey();
                Environment.Exit(1);
            }
            return(null);
        }