When writing a new image node with the HTMLAgilityPack, it seems to remove the closing tag for the image, as in should be but has when you examine the outer html.
string strIMG = "<img src='" + imgPath + "' height='" + pubImg.Height + "px' width='" + pubImg.Width + "px' />"; HtmlNode newNode = HtmlNode.Create(strIMG);
This invalidates xhtml.
Micky's suggestion to tell it to produce XML works, but if you have further reasons not to want XML, try this:
doc.OptionWriteEmptyNodes = true;