I am developing an app for android, I need to create a rather large XML file.
I have tried this with a DOM document however because it resides in memory it throws an 'out of memory' error.
Can someone suggest an alternative solution? This is a XML file create from scratch.
I would write the XML to a Stream or Writer progressively as to traverse the data you want to turn into XML. This way you don't need much more memory than the original data.
You will always go out of memory for Large Data size. How about dividing your Data and creating small chuncks and then appending all those together.
Or an other option is using SAX parser which consumes less memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With