How to solve Ampersand (&) conversion issue in XML?

前端 未结 4 621
北恋
北恋 2021-01-21 06:07

I am creating XML file using XMLDocument, but when XML node get \'&\' as data, it converting in \"Ampersand(&)amp;\" but i need actual value that is \'&\', Can anyon

4条回答
  •  星月不相逢
    2021-01-21 06:18

    A single & is illegal in an XML document (outside of CDATA sections; see @rsp's answer), so this is not possible. If there is a verbatim ampersand in your node data, it has to be encoded as &.

    But it's also no problem because any XML reader will decode & as a literal & when parsing the XML file.

提交回复
热议问题