我目前正在使用HMLAgilityPack编辑html文件。
我的模板有这段html:
<model-viewer class="viewer" id="viewer1" ar ar-modes="scene-viewer quick-look" ar-scale="auto" environment-image="neutral" src="mymodel.glb" camera-controls auto-rotate></model-viewer>但是,当我编辑和保存此文档时,它会向此标记的某些部分添加一个空属性。例如,保存的html如下所示,其中ar、camera-controls和auto-rotate添加了空引号。
<model-viewer class="viewer" id="viewer1" ar="" ar-modes="scene-viewer quick-look" ar-scale="auto" environment-image="neutral" src="mymodel.glb" camera-controls="" auto-rotate=""></model-viewer>我如何停止?
ar在模型查看器中,标记变为
ar=""谢谢
发布于 2021-06-30 03:04:57
https://github.com/zzzprojects/html-agility-pack/issues/422
设置htmlDoc.GlobalAttributeValueQuote = AttributeValueQuote.WithoutValue
var html = @"<!DOCTYPE html>
<html>
<body a b c>
</body>
</html> ";
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);
htmlDoc.GlobalAttributeValueQuote = AttributeValueQuote.WithoutValue;
htmlDoc.Save(@"./test.html");
// <!DOCTYPE html>
// <html>
// <body a b c>
// </body>
// </html> https://stackoverflow.com/questions/68184219
复制相似问题