You need to sign in to do that
Don't have an account?
Sfdc_beginner
A Custom apex class to process a xml and then create records in salesforce
Hi,
I have a requirement where i need to write a custom apex class to process a xml and then create records in salesforce.
One more thing, is there any way we can process a xml located in a local drive and then create records in Salesforce.
Please share few examples.
Thanks
SFDC Beginner
If you do not have a folder/drive available to the web on your local machince, you would have to have your local machine upload this as a document.
Then i would create a trigger, so as the file is saved, say in X folder, have it process then, or use a batch job to process all unprocessed files periodically yes.
All Answers
Hi SFDC Beginner,
You would create a Visualforce page that would read a file that you upload. It's hard to explain exactly what you need as the XML file will have difference nodes. Use the XmlStreamReader to read your file and there are some examples in this discussion
Here is an exmaple how to get your XML File into a string so you can read it.
VF Page
APEX Class
Thanks zachbarkley for the quick reply, Will try implementing it and confirm.
One more question, is it possible where we can write a scheduled job (Automated) to pick up a xml file from a local path and then process it.
Thanks in advance!
Thanks
SFDC Beginner
If you do not have a folder/drive available to the web on your local machince, you would have to have your local machine upload this as a document.
Then i would create a trigger, so as the file is saved, say in X folder, have it process then, or use a batch job to process all unprocessed files periodically yes.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_System_XmlStreamReader_instance_methods.htm
Regards,
Satish Kumar
Hi There,
One more question, please share me a few examples of how to read an uploaded XML file , parse it and creating records using an Apex class.
Thanks in advance
SFDC Beginner