How to display   in XML output

dirin picture dirin · Mar 8, 2012 · Viewed 43.1k times · Source

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?

Thanks.

Answer

Francis Avila picture Francis Avila · Mar 8, 2012

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.