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

Problem when Generating an XML from VF page using ContentTyp​e

I'm attempting to retrieve XML from a VF page, but I'm not receiving XML, only some javascript.

I have a simple page:

<?xml version="1.0" encoding="UTF-8"?><apex:page contentType="application/xml">

 with being redirected to by the result of a different controller:

ResultString = '<reason>' + NewProspectStatus + '</reason>';
if(NewProspectStatus.startsWith('New Lead: '))
	ResultString = '<code>0</code>\n<description>SUCCESS</description>\n' + ResultString;
	ResultString = '<code>1</code>\n<description>ERROR</description>\n' + ResultString;
system.debug('ResultsString: ' + ResultString);
Pagereference pr = Page.ELeadThankYou;       
pr.getParameters().put('ResultString', ResultString);
system.debug('Response: ' + pr.getContent().toString());
return pr;

 But the result looks like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
var escapedHash = '';
var url = '/eleadthankyou?ResultString=%3Ccode%3E0%3C%2Fcode%3E%0A%3Cdescription%3ESUCCESS%3C%2Fdescription%3E%0A%3Creason%3ENew+Lead%3A+Buddy+Dwight+imported+from+Lead+Provider%3A+FromORG2%3C%2Freason%3E';
if (window.location.hash) {
   escapedHash = '%23' + window.location.hash.slice(1);
if (window.location.replace){ 
window.location.replace(url + escapedHash);
} else {;
window.location.href = url + escapedHash;




I've read through this post

Generating an XML from VF page using ContentTyp​e

Which is a nice intro to what I'm attempting.


Any idea why this is not returning XML?