Пример #1
0
        private static List <Page> ParseMediaWiki(XmlTextReader reader)
        {
            reader.ExpectStartElement("mediawiki");

            var pages = new List <Page>();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name == "page")
                    {
                        pages.Add(Page.Parse(reader));
                        reader.ExpectEndElement("page");
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (reader.Name == "mediawiki")
                    {
                        return(pages);
                    }
                    break;
                }
            }

            return(pages);
        }
Пример #2
0
        public static void SkipElement(this XmlTextReader reader)
        {
            var name = reader.Name;

            while (reader.Read())
            {
                if ((reader.NodeType == XmlNodeType.EndElement) && (reader.Name == name))
                {
                    break;
                }
            }

            reader.ExpectEndElement(name);
        }