How to avoid & in XML ?

2019-08-21 09:26发布

问题:

I am trying to send all data to xml through php. But somehow XML parses the data and in Password it finds & and replaces it with & after that data is posted through Curl. So is there any method / technique to avoid & in xml. Or it goes as it is. I am tried almost all encoding functions.

回答1:

Use the CDATA Section to make it leave the ampersand unchanged.



回答2:

In the normal course of events, & in the data is encoded as & in the XML, and the XML parser decodes this and presents it as & to the application. If the application (curl?) is seeing it as & this is either because it has been double-escaped in the XML (as &) or because it is not being read using a real XML parser.