0

We have created an API

We have programmed a client within sfdc using visualforce and apex controller.

In order to parse the resp we are using xmlStreamReader utility. But getting below exception if the attribute value of any xml tag has special characters.

Exception: 18:46:25.626 (626839218)|EXCEPTION_THROWN|[1160]|System.XmlException: ParseError at [row,col]:[1,152] Message: The entity name must immediately follow the '&' in the entity reference.

How to work on this ? Is there any workaround to pass

  • Can you share the portion of the XML where the error is occurring? I would be willing to bet you have an & in a string and it may need to be &amp – Eric Nov 17 '15 at 16:41
  • Yep it is , And i need to know what can be followed or need to make it work: sample xml <httpPage title="" isLoggedIn="true" year="2010" hasAccess="true"><ReportSection name="paymentSummary" title="Payments"><Record Symbol="USD" name="&" value="Current Period" amount="391"/></ReportSection></httpPage> – cloudy-ritz Nov 17 '15 at 16:52
4

It's not "XML with a special character". It's non-XML.

The error message suggests you have an ampersand followed by some character that can't legally follow an ampersand, e.g. '#' or a name-start character. That makes the document ill-formed, and that means you can't parse it as XML.

Fix the software that is producing bad XML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.