Example #1
0
        public static async Task <XmlDocument> LoadWebPageAsync(string url, LoaderOptions options)
        {
            XmlDocument xhtmlDoc = new XmlDocument();

            await LoadWebPageAsync(xhtmlDoc, url, options);

            return(xhtmlDoc);
        }
Example #2
0
        internal static async Task LoadWebPageAsync(XmlDocument doc, string url, LoaderOptions options)
        {
            LoaderOptions optionsToUse = options == null ? new LoaderOptions() : options;

            optionsToUse.ParserOptions.BaseUrl = string.IsNullOrEmpty(optionsToUse.ParserOptions.BaseUrl) ? url : optionsToUse.ParserOptions.BaseUrl;

            XmlDomBuilder dom = new XmlDomBuilder(doc);
            HtmlStreamParser <XmlNode> parser = new HtmlStreamParser <XmlNode>();

            // Get the Html asynchronously and Parse it into an Xml Document
            using (HtmlTextReader htmlReader = await HtmlClient.GetHtmlTextReaderAsync(url, optionsToUse))
                parser.Parse(dom, htmlReader, optionsToUse.ParserOptions);
        }