Escape XML Function in VisualForce?

You can use apex:outputText to escape sensitive characters. You can use it like this:

<apex:outputText value="{!record.field}" />

There's a parameter called "escape" that defaults to true; in other words, when you use this element, it naturally protects you from emitting characters that might be misinterpreted by an XML or HTML parser.


If you think that <br> tags in your formula fields are the problem, can you try to substitute them either in controller, or in outputText like this:

<apex:outputText value="{!SUBSTITUTE(Example[Field], '<br>', '<br/>')}" 
    rendered="{!Example[Field] != null}"/>