function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
anschoeweanschoewe 

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);
while(xsr.hasNext())
{
     if (xsr.getEventType() == XmlTag.START_ELEMENT && xsr.getLocalName() == 'txtProEMail') {
        xsr.next();
        if (xsr.getEventType() == XmlTag.CHARACTERS) {
            System.debug('******** Value: ' + String.escapeSingleQuotes(xsr.getText()));
        }
    }
    xsr.next();
}

 

 

---------------

 

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,

 

Andrew