0

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

1 Answer 1

3

Maybe use SAX instead of DOM? It is event-based and doesn't build huge in-memory structures.

Sign up to request clarification or add additional context in comments.

1 Comment

I do thing the same as weekens says. Use sax parser instead

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.