XML 中的换行符未显示在浏览器中,但在查看源代码中正常 [英] Line breaks in XML not showing in browser but OK in view source

查看:27
本文介绍了XML 中的换行符未显示在浏览器中,但在查看源代码中正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我生成了一个 XML 文件,其中一个节点包含我需要以特定方式使用换行符/换行符呈现的数据:

I have generated an XML file that and one of the nodes contains data that I need to be rendered in a specific way with line breaks/new lines:

这应该是第一行
这应该是第二行

This should be the first line
this should be the second line

当我在浏览器中加载 XML 并查看源代码时,我可以复制和粘贴数据并保持结构不变.然而在浏览器中它呈现为:

When I load the XML in browser and view source it looks spot on, I can copy and paste the data with the structure maintained. In the browser however it is rendered as:

这应该是第一行 这应该是第二行

This should be the first line this should be the second line

有什么想法吗?

推荐答案

XML 中没有任何内容可以帮助您在浏览器中设置文本格式.如果您想格式化 XML 数据以便在浏览器中查看,您应该将 XML 转换为 HTML 并应用适当的 HTML 标签,以便按照您希望的方式显示文本.

There is nothing in XML that would assist you with formatting text in the browser. If you want to format XML data for viewing in the browser you should transform the XML into HTML and apply the approriate HTML tags that will format the text as you want it to appear.

这篇关于XML 中的换行符未显示在浏览器中,但在查看源代码中正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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