Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How would I get away from ampersands in XML so they are delivered as entities in HTML?

I have some XML text that I wish to deliver on an HTML page. This content contains an ampersand, which I need to deliver in its entity representation: &.

How would I get away from this ampersand in the source XML? I attempted & however, this is decoded as the real ampersand character (&), which is invalid in HTML.

So I need to get away from it so that it will be delivered as & in the website page that utilizes the XML output.
by

2 Answers

ninja01
When your XML contains &, this will result in the text &.

When you use that in HTML, that will be rendered as &.
MounikaDasa
I have tried &amp, but it didn't work. Based on Wim ten Brink's answer I tried &amp and it worked.

One of my fellow developers suggested me to use & and that worked regardless of how many times it may be rendered.

Login / Signup to Answer the Question.