public bool AddSource(string url, string[] xpaths, string name) { var doc = new HtmlDocument(); if (url.IndexOf("http") != 0) { throw new Exception("Invalid source url"); } doc.LoadHtml(downloader.Download(url)); var node = doc.DocumentNode; if (xpaths != null && xpaths.Count() > 0) { try { var nodes = this.getSelector(xpaths).Item1.Invoke(doc.DocumentNode); this.Sources.Add(name, nodes); } catch (XPathException) { throw new Exception("The XPath provided for the source yields no results: " + String.Join(",", xpaths)); } } else { this.Sources.Add(name, doc.DocumentNode); } return(true); }