HtmlAgilityPack LoadHtml - Empty P Tags Issue
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, the doc.InnerHtml
following is output:
<div>something<p></div>
So you can see that it loses the closing P tag and I messed up the HTML.
I can't find a solution for this, can anyone help me.
+3
source to share
1 answer
The icon OptionWriteEmptyNodes
is what you are looking for:
Determines whether empty nodes should be written as closed during output.
And in your case:
doc.OptionWriteEmptyNodes = true;
Productivity:
<div>something<p /></div>
+1
source to share