+ Start a Discussion

Streaming XML Reader with Apostrophes

We are calling a webservice that returns it's response in XML. We've discovered that when the text of an XML tag contains an apostrophe, the text is truncated.  This is causing us problems.  Here's an example showing the problem:


String xmlString = '<txtProEmail>paul.o&apos;connor@company.com</txtProEmail>'; //paul.o'connor@company.com
XmlStreamReader xsr = new XmlStreamReader(xmlString);
     if (xsr.getEventType() == XmlTag.START_ELEMENT && xsr.getLocalName() == 'txtProEMail') {
        if (xsr.getEventType() == XmlTag.CHARACTERS) {
            System.debug('******** Value: ' + String.escapeSingleQuotes(xsr.getText()));





The debug statement always shows: paul.o

This is a problem since we are enforcing that the emails are valid.  Since it's getting truncated, it's not valid.  Any thoughts?   The 'String.escapeSingleQuotes()' call doesn't seem to affect the output.


Any help is appreciated,