如何显示 在 XML 输出中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9625602/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to display in XML output
提问by dirin
I am generating the XML output using XSLT. I need to display in the XML output. I have tried few options to display but it displays  . Can anyone help me on this issue?
我正在使用 XSLT 生成 XML 输出。我需要 在 XML 输出中显示。我尝试了几个选项来显示, 但它显示 . 任何人都可以帮助我解决这个问题吗?
Thanks.
谢谢。
回答by Francis Avila
Unless your XML has a DTD which says what means, you cannot use . The only reason this works in HTML is because the XHTML DTD defines what it means (for XHTML) or it's just baked in to the parser (HTML).
除非你的 XML 有一个 DTD 说明什么 意思,否则你不能使用 . 这在 HTML 中起作用的唯一原因是因为 XHTML DTD 定义了它的含义(对于 XHTML)或者它只是嵌入到解析器 (HTML) 中。
In general you should not use named character entities in XML because such documents cannot be parsed properly without their DTD. (And DTDs are a big hassle.) Use the character directly, or use a numeric character reference.
通常,您不应在 XML 中使用命名字符实体,因为如果没有 DTD,此类文档将无法正确解析。(而且 DTD 是个大麻烦。)直接使用字符,或者使用数字字符引用。
For a non-breaking space, you can use  or  , which are the decimal and hexadecimal unicode code point numbers respectively.
对于不间断空格,您可以使用 或 ,它们分别是十进制和十六进制的 unicode 代码点数。
回答by yeyo
I don't know if this is what you want, but, here it is anyways
我不知道这是否是您想要的,但是,无论如何都在这里
<?xml version="1.0"?>
<hello>&nbsp;</hello>
output:
输出:
<hello> </hello>
回答by Solar Fiber
Define nbspentity inline:
内联定义nbsp实体:
<!DOCTYPE inline_dtd[
<!ENTITY nbsp " ">
]>

