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
satishch_sfdcsatishch_sfdc 

Saving Http Callout Xml Response as a html file in attachments

Hi All,

I need to convert a HTTP Callout XML Response into HTML using XSLT sheets and save it as a blob file in attachments.

The behaviour of the visualforce page that i incorporated this functionality is working as expected (i can view the xml response as html with all the images and styles that are being applied from xslt sheets).

But the same behaviour is missing when i am trying to create a blob file using page.getcontent().

The source code of the Vf page and the blob file is different. So, i am unable to meet the requrement to download a html file that shows the xml response with style sheets.

Looking for help...!! 

Thanks in Advance,
Satish



AshwaniAshwani
When you get page blob using page.getcontent() in that case controller run but apex reapeat and other visualforce dynamic tags doesn't work and you get simple static unrendered visualforce page. This is the resaon you are getting different blob file. You have to create string in controller which should be didplayed directly on page without <apex:repeat> or <apex:datatable>.

Hope it helps.
satishch_sfdcsatishch_sfdc
Hi Avilion,

I am doing the same... plz go through my vf code...

<apex:page controller="controller" sidebar="false" showHeader="false" cache="true" wizard="true" contentType="application/xml">
<?xml version="1.0" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="{!URLFOR($Resource.StyleSheets, '/profile/PPR.xslt')}"?>
{!strString}
</apex:page

The Stirng "strString" contains XML response generated through Http callout. In line no 3 i am appending xslt sheets that converts xml into html.
My approcah is working fine on vf page and the source code is html.

I need this html source code but not static content as a blob file. How to acheive this?

Thank you.

Avidev9Avidev9
You can do something like this

PageReference pr = Page.YOUR_PAGE_NAME_HERE;
 String HTMLpageText = pr.getContent().toString();