parsing XML with ampersand

后端 未结 9 1388
孤城傲影
孤城傲影 2020-11-30 12:21

I have a string which contains XML, I just want to parse it into Xelement, but it has an ampersand. I still have a problem parseing it with HtmlDecode. Any suggestions?

9条回答
  •  北海茫月
    2020-11-30 12:49

    You should 'encode' rather than decode. But calling HttpUtility.HtmlEncode will not help you as it will encode your '<' and '>' symbols as well and your string will no longer be an XML.

    I think that for this case the best solution would be to replace '&' with '& amp;' (with no space)

提交回复
热议问题