Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: Can't seem to remove nodes

$
0
0
Embarrasingly trivial problem, but I've only ever used HAP for scraping websites and never tried to manipulate the html.

I'm trying to remove an img node and neither of the approaches listed below seem to work.

(A)
HtmlAgilityPack.HtmlNode tipGif = 
                    doc.DocumentNode.SelectSingleNode("//img[@src = 'http://www.stuff.com/ico/annoying-gif.gif']");

                if (tipGif != null)
                {
                    var nodesToRemove = doc.DocumentNode
                    .SelectNodes("//img[@src = 'http://www.stuff.com/ico/annoying-gif.gif']")
                   .ToList();

                    foreach (var node in nodesToRemove)
                       node.Remove();
            }
(B)
var RL = doc.DocumentNode.SelectSingleNode("//img[@src = '
http://www.stuff.com/ico/annoying-gif.gif']");
RL.Remove();
I think I'm missing something fundamental about how this method works. I can post an example of the html but it's very vanilla.

Thanks in advance.

Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>