HTML 在 .NET 中呈现不正确
我试图在 VB.NET 中获取字符串“
”并通过 XSLT 将其转换为 HTML。 然而,当 HTML 出来时,它看起来像这样:
<BR>
我只能假设它会继续并尝试渲染它。 有什么方法可以将这些 </>
转换回括号中,以便我得到我想要的换行符吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
检查 XSLT 是否具有:
编辑:注释中的解释
默认情况下,XSLT 输出为 XML(1),这意味着它将转义任何重要字符。 您可以在特定实例中使用属性
disable-output-escaping="yes"
覆盖此设置(简介 此处),但更强大的是将输出更改为 HTML 的显式值,这在全局范围内具有相同的好处,如下所示:来自涵盖该主题的可靠 IBM 文章, stylusstudio 此处的最新报道
如果 HTML 输出是您想要的想要的 HTML 输出是您应该指定的。
(1) 实际上存在输出默认为 HTML 的极端情况,但我认为它不是通用的,而且依赖它有点迟钝。
Check the XSLT has:
edit: explanation from comments
By default XSLT outputs as XML(1) which means it will escape any significant characters. You can override this in specific instances with the attribute
disable-output-escaping="yes"
(intro here) but much more powerful is to change the output to the explicit value of HTML which confides same benefit globally, as the following:from a solid IBM article covering the subject, more recent coverage from stylusstudio here
If HTML output is what you desire HTML output is what you should specify.
(1) There is actually corner case where output defaults to HTML, but I don't think it's universal and it's kind of obtuse to depend on it.
尝试用
<br>
包裹它Try wraping it with
<xsl:text disable-output-escaping="yes"><br></xsl:text>
不了解 XSLT,但是..
一种解决方法可能是使用 HttpUtility.HtmlDecode。
...
Don't know about XSLT but..
One workaround might be using HttpUtility.HtmlDecode from System.Web namespace.
...
知道了! 除了选定的答案之外,我还在我的字符串上做了类似的事情:
不过,我认为最终我可能只是使用
Got it! On top of the selected answer, I also did something similar to this on my string:
I think, though, that in the end, I may just end up using
<pre>
tags to preserve everything.字符串“
”已经是 HTML,因此您只需Response.Write("
即可。")
但你指的是 XSLT,所以我想正在进行一些转换。 在这种情况下,变换肯定应该将其作为节点插入到正确的位置。 更好的问题可能会得到更好的答案
The string "
<br>
" is already HTML so you can justResponse.Write("<br>")
.But you meantion XSLT so I imagine there some transform going on. In that case surely the transform should be inserting it at the correct place as a node. A better question will likely get a better answer