我正在使用 xslt 将 xml 文件转换为 html..net xslt 引擎一直为我提供空标签的自闭合标签.
I am using xslt to transform an xml file to html. The .net xslt engine keeps serving me self-closing tags for empty tags.
例子:
<div class="test"></div>
变成
<div class="test" />
前者是合法的html,而后者是非法的html,渲染不好.我的问题是:如何告诉 xslt 引擎 (XslCompiledTransform) 不使用自闭合标签.
The former is valid html, while the latter is illegal html and renders badly. My question is : How do I tell the xslt engine (XslCompiledTransform) to not use self-closing tags.
如果不可能,我如何告诉我的浏览器(在这种情况下为 IE6+)正确解释自闭标签.
If it's not possible, how can I tell my browser (IE6+ in this case) to interpret self-closing tags correctly.
如果您使用 XmlWriter 作为输出流,请改用 HTMLTextWriter.XMLWriter 会将您的 HTML 输出重新格式化为 XML.
If you are using XmlWriter as your ouput stream, use HTMLTextWriter instead. XMLWriter will reformat your HTML output back to XML.
这篇关于XSLT 自闭标签问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!