Esempio n. 1
0
        public static XMLTree ParseLesson(string filePath)
        {
            XmlReaderSettings settings = new XmlReaderSettings(); // allows us to ignore comments and only access nodes and relevant information

            settings.IgnoreComments   = true;
            settings.IgnoreWhitespace = true;

            XmlReader reader = XmlReader.Create(filePath, settings);

            reader.Read(); // get to correct xml tag

            XMLTree tree = new XMLTree(reader.Name);

            RParser(reader, reader.Name, tree);

            return(tree);
        }
Esempio n. 2
0
        public static void RParser(XmlReader reader, string tagName, XMLTree node)
        {
            while (reader.Read())
            {
                if (reader.Name == tagName)
                {
                    return;
                }                        // IF END OF TAG BASECASE

                if (reader.Name == "")   // IF VALUE
                {
                    node.content = reader.Value;
                }

                else if (reader.Name != tagName)   // IF NEW TAG
                {
                    XMLTree child = new XMLTree(reader.Name);
                    node.AddChild(child);
                    RParser(reader, reader.Name, child);
                }
            }
        }
Esempio n. 3
0
 public void AddChild(XMLTree child)
 {
     this.children.Add(child);
 }