+ Start a Discussion

reading/storing and parsing big (~70-80 MB) XML file


I need help in reading/storing and parsing big (~70-80 MB) XML file.

1] As per our requirement, the third party system will upload the xml on secure ftp, which we will need to bring in Salesforce.
I know Salesforce doesn't support FTP natively, I amy need to introduce a java/dotnet app in between or go for third party solutions like Jittebit or dataloader.io.

2] This xml will contain 2000-3000 records, each with approx 150 fields. We will need to prse this big xml, and upsert these records.
I have used Apex DOM to parse xmls in Salesforce, but not sure it will be the appropriate for our requirement.

​Any recommended appraoches for these requirements?

john yungkjohn yungk
I agree that a DOM parser probably isn't the correct approach for a large XML file and would suggest looking at a streaming parser (XmlStreamReader)
As a POC, I inserted 8MB xml as an attchment and tried to parse the same using DOM/XmlStreamReader, but it threw the below exception for both while loading xml contents:
String length exceeds maximum: 6000000.
So looks like Salesforce will not be able to parse a big xml with size of 70-80 MB. 
The xml which we need to parse has lots of nodes which we don't need. Is there any way to pull out only the required nodes first and then try to parse this truncated xml to avoid 'String length exceeds maximum: 6000000' exception?
Anoop ViswambharanAnoop Viswambharan
Hi Amey,

I am also getting the same error when trying to parse large XML file. Did you find any solution for this issue?