/// <summary>Gets page titles and page text from local XML dump. /// This function consumes much resources.</summary> /// <param name="filePathName">The path to and name of the XML dump file as string.</param> public void FillAndLoadFromXMLDump(string filePathName) { Bot.LogEvent(Bot.Msg("Loading pages from XML dump...")); XmlReader reader = XmlReader.Create(filePathName); while (reader.ReadToFollowing("page")) { Page p = new Page(site, ""); p.ParsePageXML(reader.ReadOuterXml()); pages.Add(p); } reader.Close(); Bot.LogEvent(Bot.Msg("XML dump loaded successfully.")); }
/// <summary>Loads text and metadata for pages in PageList via XML export interface. /// Non-existent pages will be automatically removed from the PageList. /// Please, don't use this function when going to edit big amounts of pages on /// popular public wikis, as it compromises edit conflict detection. In that case, /// each page's text should be loaded individually right before its processing /// and saving.</summary> public void LoadEx() { if (IsEmpty()) throw new WikiBotException(Bot.Msg("The PageList is empty. Nothing to load.")); Bot.LogEvent(Bot.Msg("Loading {0} pages..."), pages.Count); string res = site.site + site.indexPath + "index.php?title=Special:Export&action=submit"; string postData = "curonly=True&pages="; foreach (Page page in pages) postData += HttpUtility.UrlEncode(page.title) + "\r\n"; XmlReader reader = XmlReader.Create( new StringReader(site.PostDataAndGetResultHTM(res, postData))); Clear(); while (reader.ReadToFollowing("page")) { Page p = new Page(site, ""); p.ParsePageXML(reader.ReadOuterXml()); pages.Add(p); } reader.Close(); }
/// <summary>Gets page titles and page text from local XML dump. /// This function consumes much resources.</summary> /// <param name="filePathName">The path to and name of the XML dump file as string.</param> public void FillAndLoadFromXMLDump(string filePathName) { Console.WriteLine("Loading pages from XML dump..."); XmlReader reader = XmlReader.Create(filePathName); while (reader.ReadToFollowing("page")) { Page p = new Page(site, ""); p.ParsePageXML(reader.ReadOuterXml()); site.messages.pages.Add(p); } Console.WriteLine("XML dump loaded successfully."); }