Example #1
0
        internal override IContentSource Crawl(IContentSource content, bool asList)
        {
            if (content == null)
            {
                return(GetDefault(string.Format("Null content")));
            }

            if (content.GetType() != typeof(XmlContent) && content.GetType() != typeof(XHtmlContent))
            {
                // convert to XHTML
                var strContent = content.ToString();
                content = new XHtmlContent();
                content.LoadRaw(strContent);
            }

            if (content.GetType() == typeof(XHtmlContent))
            {
                content = asList ? (content as XHtmlContent).CrawlList(XPath) : (content as XHtmlContent).Crawl(XPath);
            }
            else     //if (content.GetType() == typeof(XmlContent)) // last case
            {
                content = asList ? (content as XmlContent).CrawlList(XPath) : (content as XmlContent).Crawl(XPath);
            }

            if (content == null)
            {
                return(GetDefault(string.Format("Null content")));
            }

            return(content);
        }
        internal override IContentSource Crawl(IContentSource content, bool asList)
        {
            if (content == null)
                return GetDefault(string.Format("Null content"));

            if (content.GetType() != typeof(XmlContent) && content.GetType() != typeof(XHtmlContent)) {
                // convert to XHTML
                var strContent = content.ToString();
                content = new XHtmlContent();
                content.LoadRaw(strContent);
            }

            if (content.GetType() == typeof(XHtmlContent)) {
                content = asList ? (content as XHtmlContent).CrawlList(XPath) : (content as XHtmlContent).Crawl(XPath);
            } else { //if (content.GetType() == typeof(XmlContent)) // last case
                content = asList ? (content as XmlContent).CrawlList(XPath) : (content as XmlContent).Crawl(XPath);
            }

            if (content == null)
                return GetDefault(string.Format("Null content"));

            return content;
        }