Reputation: 2282
I am trying to load simple html:
var html = "<div>something<p></p></div>";
var doc = new HtmlDocument();
doc.LoadHtml(html);
After loading this HTML doc.InnerHtml
outputs this:
<div>something<p></div>
So as you can see it loses closing P tag and I got messed HTML.
I cannot find any solution for this, can anyone help me please.
Upvotes: 3
Views: 800
Reputation: 49133
The OptionWriteEmptyNodes
flag is what you're looking for:
Defines if empty nodes must be written as closed during output.
And in your case:
doc.OptionWriteEmptyNodes = true;
Yields:
<div>something<p /></div>
Upvotes: 1