I saved an XML template file like the below in a library. Please note the text ApplicationTypeHolder and SubmissionTypeHolder in the file. I modified the original XML file and added those texts there. I have an object A. In detail view of the record of Object A, there is a vf page from where user can click a button generate a new XML file which has the Application Type value and Submission Type value. I replace those texts in apex with the respective object field values. Once the new XML file with data is generated it will be added as an attachment to the record.
<sfAppinfoFlow> <sfAppPos> <chkSmallEntity>0</chkSmallEntity> <class /> <subclass /> <us_suggested-tech_center /> <us-total_number_of_drawing-sheets /> <us-suggested_representative_figure /> <application_type> ApplicationTypeHolder </application_type> <us_submission_type> SubmissionTypeHolder </us_submission_type> </sfAppPos> </sfAppinfoFlow>
This was a simple task, The XML file was 1.5 MB in size. But We only needed to fill a few tags. Now this is getting complex as now we have to replicate the tags based on related items. For ex, if the record has 2 classes associate with that then I need to add two tags, also the heap size is getting bigger. What is the alternative solution to this.
I have seen a few XMLreader and dom.document class examples. XMLreader is used for inserting data into obj while dom.document was used to create a new xml file.