图像标记未使用HTMLAgilityPack关闭 [英] Image tag not closing with HTMLAgilityPack

查看:81
本文介绍了图像标记未使用HTMLAgilityPack关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用HTMLAgilityPack写出新的图像节点,似乎删除了图像的结束标记,例如应该是,但是当您检查外部html时,具有.

Using the HTMLAgilityPack to write out a new image node, it seems to remove the closing tag of an image, e.g. should be but when you check outer html, has .

string strIMG = "<img src='" + imgPath + "' height='" + pubImg.Height + "px' width='" + pubImg.Width + "px' />";

HtmlNode newNode = HtmlNode.Create(strIMG);

这会破坏xhtml.

推荐答案

按照Micky的建议将其输出以输出XML,但是如果您还有其他不想要XML的理由,请尝试以下操作:

Telling it to output XML as Micky suggests works, but if you have other reasons not to want XML, try this:

doc.OptionWriteEmptyNodes = true;

这篇关于图像标记未使用HTMLAgilityPack关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆