Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private XmlParser LoadParser()
        {
            XmlParser parser = new AdvancedXmlParser();

            parser.Document = XDocument.Parse(
                @"<root>
                                <ime testAtt=""testAtt"">Rok</ime>
                                <ime testAtt2=""testAtt2"">Rok2</ime>
                                <priimek>Dolinar</priimek>
                                <priimek>Dolinar2</priimek>
                                <kraj>Javorje 34</kraj>
                                <sola>
                                  <ime_sole>FRI</ime_sole>
                                  <lokacija>Vecna pot</lokacija>
                                </sola>
                              </root>");
            return(parser);
        }