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

前端 未结 11 1810
野趣味
野趣味 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:59

    In my case I had to change it to %26.

    I needed to escape & in a URL. So & did not work out for me. The urlencode function changes & to %26. This way neither XML nor the browser URL mechanism complained about the URL.

提交回复
热议问题