I have some XML text that I wish to render in an HTML page. This text contains an ampersand, which I want to render in its entity representation: &
.
&
is the way to represent an ampersand in most sections of an XML document.
If you want to have XML displayed within HTML, you need to first create properly encoded XML (which involves changing &
to &
) and then use that to create properly encoded HTML (which involves again changing &
to &
). That results in:
&
For a more thorough explanation of XML encoding, see:
What characters do I need to escape in XML documents?