Before posting I tried the solution from this thread:
C# - Remove spaces in HTML source in between markups?
Here is a snippet of the HTML I'm working with:
<p>This is my text</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>This is next text</p>
I'm using HTML Agility Pack to clean up the HTML:
HtmlDocument doc = new HtmlDocument();
doc.Load(htmlLocation);
foreach (var item in doc.DocumentNode.Descendants("p").ToList())
{
if (item.InnerHtml == " ")
{
item.Remove();
}
}
The output of the code above is
<p>This is my text</p>
<p>This is next text</p>
So my problem is how do I remove the extra whitespace between the two paragraphs in the HTML source.
`. What you should do is `item.InnterHtml=string.Empty`.
– Chetan Apr 03 '17 at 04:11