Currently, I have been trying to generate XML in the simplest way possible. So far I have almost everything except for one minute detail.
Currently, I am trying to print out the following:
<?xml version="1.0" encoding="UTF-8" ?>
However, whenever I try that, it blows up the page with this:
Currently, I have only seen two options, actually three if I just leave it out entirely.
The first option is to change the API version of the page to 19. I got the whole idea for generating my XML via a VisualForce page here. The only problem is, I am using dynamic references to access the fields on my custom object (the main reason I chose this route in the first place). So this is a no-go for me.
The second, which used to work I believe, is to use a non-escaped output tag.
Basically, this:
<apex:page standardController="Example__c" extensions="ExampleResponseController"
recordSetVar="Examples"
contentType="text/xml" showHeader="false" sidebar="false" cache="false">
<apex:outputText value="<?xml version="1.0" encoding="UTF-8" ?>" escape="false"/>
<response>
<apex:repeat value="{!ExamplesToHaveXML}" var="Example">
<apex:outputText value="<Example id="{!Example.Id}">" escape="false"/>
<apex:repeat value="{!ExampleFields}" var="Field">
<apex:outputText value="<{!Field}>" escape="false"/>
<apex:outputText value="{!Example[Field]}"/>
<apex:outputText value="</{!Field}>" escape="false"/>
</apex:repeat>
<apex:outputText value="</Example>" escape="false"/>
</apex:repeat>
</response>
</apex:page>
This works great for generating all the other XML tags, but not the most important one. I check to see if it rendered properly in HTML - which it did - but, when I change the content type of the page to XML, it blows up.
I don't know if I can forgo this tag altogether because the rest of it actually works. I just have no idea why of all things, this has to be the issue. Any thoughts?