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
Swamy P R NSwamy P R N 

download xml file by click a button on VF page

Hi buddys,

I have a VF page like the below one.Now when i am going to click on "OK" Button,i need to download that XML file and  i need to insert that XML file in related Attachments.Any idea...

<apex:page showHeader="false" controller="CLS_xmlGeneration" tabStyle="Reward__c">
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageBlockSection collapsible="false">
                <apex:outputText value="{!xmldata}" style="width:1000px;"></apex:outputText>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Back" onclick="window.top.close();"/>
                <apex:commandButton value="OK" onclick="window.open('/{!recid}?export=1&enc=UTF-8&xf=csv');"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>


XML :
<?xml version="1.0"?><Reward><Id>a04i000000AhEc8AAF</Id><Name>R-0001</Name><UserId>005i0000002hsAbAAI</UserId><TimeId>a01i000000AoSiWAAV</TimeId><RewardAmount>500</RewardAmount></Reward>
Ashish_SFDCAshish_SFDC
Hi Swamy, 


See the below thread for downloading the XML file, 

https://developer.salesforce.com/forums?id=906F000000098gWIAQ

See the below thread for adding the File to the Attachments, 

https://developer.salesforce.com/forums/ForumsMain?id=906F00000009Fq0IAE


Regards,
Ashish