Thursday, November 7, 2013

How to remove nodes in HTMLAgilityPack? Such as remove all of invisible div?

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml(html);
            var Divs = doc.DocumentNode.SelectNodes("//div[(contains(@style,'display:none'))]");
            if (noneDivs != null)
            {
                foreach (var one in noneDivs.ToList())
                {
                    one.Remove();
                }
            }

No comments:

Post a Comment