Reputation: 1
I'm trying to parse large xml with Dom parser in android.The xml file size exceed 1Mb
I'm using this code,
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(istream); // normalize text representation
doc.getDocumentElement().normalize();
i got an out of memory exception, at
Document doc = docBuilder.parse(istream);
//this line
Is there any way to cope with this issue , I'm working on android eclipse emulator. Any help in this regards greatly appreciated. Thanks
Upvotes: 0
Views: 749
Reputation: 8292
Maybe use SAX instead of DOM? It is event-based and doesn't build huge in-memory structures.
Upvotes: 3