The Real Roxette
The Real Roxette

Reputation: 159

How to properly encode HTML within XML in PHP for SOAP

I'm attempting to communicate with Exchange 2007, and there are known bugs/problems with doing UpdateItem() so I'm manually communicating over cURL, building my own XML instead of letting the SOAP client do it. It all works fine, but I need to be able to properly encode HTML to fit within the elements of XML.

I know about html_encode() and htmlspecialchars() but I am unsure whether or not these are proper to use and whether or not in the future it may not encode correctly, and screw up the SOAP communication.

As a side note, if it matters, the communication will be in both English and Russian, so it needs to be Unicode safe.

Upvotes: 0

Views: 1707

Answers (1)

Sjoerd
Sjoerd

Reputation: 75659

Html_encode will use HTML entities. HTML entities are defined for HTML, but not for XML, so this won't work.

Escaping tags in XML is done by wrapping your content in CDATA tags. Special characters (üéâä) can be represented in UTF8.

Upvotes: 1

Related Questions