San
San

Reputation: 1837

Loading HTML string using HTMLAgilityPack

I am loading HTML passed as string into HTMLAgilityPack document as below.

 HtmlDocument html = new HtmlDocument();
 html.OptionOutputAsXml = true;
 html.LoadHtml(htmlText);
 HtmlNode document = html.DocumentNode;

After loading the document.InnerHtml shows up with &quot(sample below) for all the quotes.How can I avoid this?

<span style=\"\\&quot;MARGIN-LEFT:\" class=\"\\&quot;form_title\\&quot;\" _20px5c_22_=\"\">MyText</span>

I would want the sample to be displayed as below.

<span class=\"form_title\" style=\"MARGIN-LEFT: 20px\">MyText</span>

From the obtained "document" I have to loop and find elements(using fizzler component). But with "&quot" appearing I am not able to do so.

Upvotes: 1

Views: 13385

Answers (1)

San
San

Reputation: 1837

Issue resolved after adding

HtmlAgilityPack.HtmlNode.ElementsFlags.Remove("form"); 
HtmlDocument html = new HtmlDocument();
html.OptionAutoCloseOnEnd = true;

Upvotes: 4

Related Questions