1

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.

4
  • 1
    Isn't CDATA an option here? Commented Jul 15, 2011 at 15:09
  • I'm not sure, I can't seem to find any examples of CDATA being used with Exchange 2007 SOAP. Commented Jul 15, 2011 at 15:11
  • What about XHTML, or just well-formed HTML? Commented Jul 15, 2011 at 17:23
  • It's updating calendar event information in Exchange which is HTML 4.01, even then it has to be encoded. Like <br> to &gt;br&lt; Commented Jul 15, 2011 at 17:53

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

nitpicks: htmlspecialchars would work tough. Wrapping the content into CDATA tags is not "escaping".
After a lot of searching and testing, htmlspecialchars actually seems to work, but Exchange doesn't seem to like CDATA in the particular elements I've attempted to use it in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.