user222427
user222427

Reputation:

HTMLAgilityPack stripping out html

I'm sure this question has asked before and i've looked before I cant find the answer, or maybe I am just doing something wrong.

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(indivdualfix[0]);             
                HtmlWeb hwObject = new HtmlWeb();
                HtmlAgilityPack.HtmlDocument htmldocObject = hwObject.Load(indivdualfix[0]);
                HtmlNode body = htmldocObject.DocumentNode.SelectSingleNode("//body");
                body.Attributes.Remove("style");
                foreach (var a in body.Attributes.ToArray())
                    a.Remove();
                string bodywork = body.InnerHtml.ToString();

The string body still returns all the html coding. I might be missing something really small here. What needs to be doen to remove all the html coding basically.

Upvotes: 2

Views: 1105

Answers (1)

Rich Tebb
Rich Tebb

Reputation: 7126

Use body.InnerText not body.InnerHtml

Upvotes: 3

Related Questions