How to display   in XML output How to display   in XML output xml xml

How to display   in XML output


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).

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.

For a non-breaking space, you can use   or  , which are the decimal and hexadecimal unicode code point numbers respectively.


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>


Define nbsp entity inline:

<!DOCTYPE inline_dtd[<!ENTITY nbsp "&#160;">]>