Exemple #1
0
        /// <summary>
        /// 导入XML
        /// </summary>
        /// <param name="filename"></param>
        public void LoadBook(string filename)
        {
            XmlHandle xmlhandle = new XmlHandle(filename);
            rule = xmlhandle.GetValue("book", "rule");
            baseurl = xmlhandle.GetValue("book", "baseurl");
            title = xmlhandle.GetValue("book/title");
            auther = xmlhandle.GetValue("book/auther");
            cover = xmlhandle.GetValue("book/cover");
            introduction = xmlhandle.GetValue("book/introduction");
            int count = xmlhandle.GetCount("book/catalogs/catalog");
            catalogs = new List<BookCatalog>();
            for (int i = 1; i <= count; i++)
            {
                BookCatalog bc = new BookCatalog();
                bc.index = Convert.ToInt32(xmlhandle.GetValue("book/catalogs/catalog[" + i + "]", "index"));
                bc.url = xmlhandle.GetValue("book/catalogs/catalog[" + i + "]", "url");
                bc.text = xmlhandle.GetValue("book/catalogs/catalog[" + i + "]");
                bc.page = new BookPage();
                bc.page.index = bc.index;
                bc.page.text = xmlhandle.GetValue("book/content/page[" + i + "]");

                catalogs.Add(bc);
            }
        }
Exemple #2
0
        public static void LoadXml()
        {
            XmlHandle xmlhandle = new XmlHandle(bookrulexml);
            int num = xmlhandle.GetCount("BookSite");
            if (num > 0) _rulelist = new List<BookRule>();
            for (int i = 1; i <= num; i++)
            {
                BookRule rule = new BookRule();
                rule.name = xmlhandle.GetValue("BookSite[" + i + "]", "Name");
                rule.url = xmlhandle.GetValue("BookSite[" + i + "]", "Url");
                rule.charset = xmlhandle.GetValue("BookSite[" + i + "]", "charset");
                rule.title_rule = xmlhandle.GetValue("BookSite[" + i + "]/title");
                rule.auther_rule = xmlhandle.GetValue("BookSite[" + i + "]/auther");
                rule.cover_rule = xmlhandle.GetValue("BookSite[" + i + "]/cover");
                rule.introduction_rule = xmlhandle.GetValue("BookSite[" + i + "]/introduction");
                rule.catalog_rule = xmlhandle.GetValue("BookSite[" + i + "]/catalog");
                rule.content_rule = xmlhandle.GetValue("BookSite[" + i + "]/content");
                _rulelist.Add(rule);
            }

            num = xmlhandle.GetCount("SearchSite");
            if (num > 0) _searchrulelist = new List<SearchRule>();
            for (int i = 1; i <= num; i++)
            {
                SearchRule rule = new SearchRule();
                rule.name = xmlhandle.GetValue("SearchSite[" + i + "]", "Name");
                rule.searchurl = xmlhandle.GetValue("SearchSite[" + i + "]", "SearchUrl");
                rule.charset = xmlhandle.GetValue("SearchSite[" + i + "]", "charset");

                rule.list_rule = xmlhandle.GetValue("SearchSite[" + i + "]", "list");

                rule.conditions =new List<RuleConditions>();
                rule.title_rule = xmlhandle.GetValue("SearchSite[" + i + "]/title");
                XmlAttributeCollection attcoll = xmlhandle.GetAttributes("SearchSite[" + i + "]/title");
                foreach (XmlAttribute v in attcoll)
                {
                    RuleConditions cond = new RuleConditions();
                    cond.name = "title";
                    cond.conditionName = v.Name;
                    cond.conditionValue = v.Value;
                    rule.conditions.Add(cond);
                }
                rule.auther_rule = xmlhandle.GetValue("SearchSite[" + i + "]/auther");
                attcoll = xmlhandle.GetAttributes("SearchSite[" + i + "]/auther");
                foreach (XmlAttribute v in attcoll)
                {
                    RuleConditions cond = new RuleConditions();
                    cond.name = "auther";
                    cond.conditionName = v.Name;
                    cond.conditionValue = v.Value;
                    rule.conditions.Add(cond);
                }
                rule.cover_rule = xmlhandle.GetValue("SearchSite[" + i + "]/cover");
                attcoll = xmlhandle.GetAttributes("SearchSite[" + i + "]/cover");
                foreach (XmlAttribute v in attcoll)
                {
                    RuleConditions cond = new RuleConditions();
                    cond.name = "cover";
                    cond.conditionName = v.Name;
                    cond.conditionValue = v.Value;
                    rule.conditions.Add(cond);
                }

                rule.introduction_rule = xmlhandle.GetValue("SearchSite[" + i + "]/introduction");
                attcoll = xmlhandle.GetAttributes("SearchSite[" + i + "]/introduction");
                foreach (XmlAttribute v in attcoll)
                {
                    RuleConditions cond = new RuleConditions();
                    cond.name = "introduction";
                    cond.conditionName = v.Name;
                    cond.conditionValue = v.Value;
                    rule.conditions.Add(cond);
                }

                rule.bookurl_rule = xmlhandle.GetValue("SearchSite[" + i + "]/bookurl");
                attcoll = xmlhandle.GetAttributes("SearchSite[" + i + "]/bookurl");
                foreach (XmlAttribute v in attcoll)
                {
                    RuleConditions cond = new RuleConditions();
                    cond.name = "bookurl";
                    cond.conditionName = v.Name;
                    cond.conditionValue = v.Value;
                    rule.conditions.Add(cond);
                }

                _searchrulelist.Add(rule);
            }
        }