How do I escape ampersands in XML so they are rendered as entities in HTML?

前端 未结 11 1811
野趣味
野趣味 2020-11-22 15:59

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: &.

11条回答
  •  温柔的废话
    2020-11-22 16:42

    I have tried &, 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.

提交回复
热议问题