public static HtmlNodeCollectionResult ExtractNodeCollection(string html, ParseBy parseBy) { var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var nodeCollection = htmlDocument.DocumentNode.SelectNodes(parseBy.BuildXPath()); if (nodeCollection == null) { return(new HtmlNodeCollectionResult { Success = false, NodeCollection = null }); } else { return(new HtmlNodeCollectionResult { NodeCollection = nodeCollection }); } }
public static HtmlSingleNodeResult ExtractSingleNode(string html, ParseBy parseBy) { var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); var singleNode = htmlDocument.DocumentNode.SelectSingleNode(parseBy.BuildXPath()); if (singleNode == null) { return(new HtmlSingleNodeResult { Success = false, HtmlNode = null }); } else { return(new HtmlSingleNodeResult { HtmlNode = singleNode }); } }