使用HTMLAgilityPack写出一个新的图像节点,它似乎删除了一个图像的结束标记,例如应该是,但是当你检查外部html时,有.
string strIMG = "<img src='" + imgPath + "' height='" + pubImg.Height + "px' width='" + pubImg.Width + "px' />";
HtmlNode newNode = HtmlNode.Create(strIMG);
Run Code Online (Sandbox Code Playgroud)
这打破了xhtml.
Rah*_*hul 19
告诉它输出XML,因为Micky建议有效,但如果你有其他理由不想要XML,试试这个:
doc.OptionWriteEmptyNodes = true;
Run Code Online (Sandbox Code Playgroud)
有一个打开 XML 输出的选项可以解决此问题。
var htmlDoc = new HtmlDocument();
htmlDoc.OptionOutputAsXml = true;
htmlDoc.LoadHtml(rawHtml);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6587 次 |
| 最近记录: |