var emptyImages = doc.DocumentNode .Descendants("img") .Where(x => x.Attributes["src"] == null || x.Attributes["src"].Value == String.Empty) .Select(x => x.XPath) .ToList(); emptyImages.ForEach(xpath => { var node = doc.DocumentNode.SelectSingleNode(xpath); if (node != null) { node.Remove(); } });
Krzysztof Radzimski
source share