public static InnerTextCollectionResult ParseInnerTextCollection(this HtmlNodeCollectionResult htmlNodeCollection, bool ensureOnlyNotNullOrEmpty = true) { var innerTextCollection = new InnerTextCollectionResult(); if (htmlNodeCollection.NodeCollection == null) { innerTextCollection.Success = false; return(innerTextCollection); } foreach (var htmlNode in htmlNodeCollection.NodeCollection) { string result = htmlNode.GetValueFromNode(); if (string.IsNullOrEmpty(result) && ensureOnlyNotNullOrEmpty) { innerTextCollection.Success = false; } else { innerTextCollection.TextCollection.Add(result); } } return(innerTextCollection); }
public static HtmlNodeSingleCollectionResult ForEachSingleNode(this HtmlNodeCollectionResult htmlNodeCollectionResult, ParseBy parseBy, bool ensureOnlyNotNull = true) { var singleNodeCollection = new HtmlNodeSingleCollectionResult(); foreach (var node in htmlNodeCollectionResult.NodeCollection) { var partialNode = node.SelectSingleNode(parseBy.Value); if (partialNode == null && ensureOnlyNotNull) { singleNodeCollection.Success = false; } singleNodeCollection.HtmlNodes.Add(partialNode); } return(singleNodeCollection); }