Activity Forums Salesforce® Discussions In Salesforce, We use XML file in Visualforce pages. What does this mean?

  • Satyakam

    Member
    December 6, 2016 at 7:10 am

    Hi sushant,

    we can download xml file using contentType in visualforce page.

    <apex:page controller="TestController" contentType="application/xml">

    ..........................

    </apex:page>

    we use xml file to upload in salesforce using visualforce page and apex controller.

    Visualforce page-

    <apex:page standardController="Account" extensions="attachmentsample">
    
    <apex:form >
     <apex:sectionHeader title="Upload an Attachment"/>
     <apex:pageblock >
     <apex:pageblocksection columns="1">
     <apex:inputfile value="{!myfile.body}" filename="{!myfile.Name}" />
     <apex:commandbutton value="Save" action="{!Savedoc}"/>
     </apex:pageblocksection>
     </apex:pageblock> 
    </apex:form> 
    
    </apex:page>

    Apex Controller-

    public class attachmentsample {
    
     public attachmentsample(ApexPages.StandardController controller) {
    
     }
     Public Attachment myfile;
     Public Attachment getmyfile()
     {
     myfile = new Attachment();
     return myfile;
     }
     
     Public Pagereference Savedoc()
     {
     String accid = System.currentPagereference().getParameters().get('id');
    
     Attachment a = new Attachment(parentId = accid, name=myfile.name, body = myfile.body);
     
     /* insert the attachment */
     insert a;
     return NULL;
     } 
    
    }

    This may help you to understand,why we use xml file in salesforce.

    Thanks

     

    • This reply was modified 8 years ago by  Satyakam.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos