views:

59

answers:

1

Hey awesome SO users,

I have an Android application that parses an XML file for users and displays results in a much more mobile friendly format. The app works great for most users, but some users have lots and lots of data and the app crashes on them because it runs out of memory.

Is there any way I have a DOM style XML parser quit parsing data after a certain amount of parsing? I only need the first 30 or so elements so it would make the application much more efficient.

I'd like to use a SAX or pull parser instead, but the XML I'm parsing is not valid and I have no control over it. Unless anyone has some good SAX solutions that let me parse messy, invalid XML, I think DOM is the only way to go.

Thanks for reading!

A: 

This might not be the best solution, but here's what I ended up doing.

I'm using HTTPClient to grab the files, I figured out what the smallest possible size of the file could be where it still has the amount of the data I need and used that information to set the range header of the request.

This causes the request to only return a partial response, but it works in my situation.

tonyc