Traverse a XML file in Android

Jame Baond

New Member
I'm developing an app in Android and I need to traverse a xml file.I need to traverse a xml - backwards and forward from a given position. It means i start to parse the file, but at each instant i can stop and go backwards or continue.I was thinking in using DOM, with its for cycle i could control it and do what i wanted. But the xml file that i want to parse has at least 8 Mb and since DOM is very memory intensive, don't seem to be a good solution.A solution to this problem was not to load the whole document for parsing. Like to split the document in several parts and only load one part to memory and parse. When i come to the end of this part, i load another. The same when i want to rewind.My question is, how can i achieve to split the file in several pieces. Since it is a xml file and the childs don't have all the same size ?For example:\[code\]<root> <child time="A"> <sub1>1</sub1> <sub2>2</sub2> </child> <child time="B"> <sub1>3</sub1> </child> <child time="C"> <sub2>4</sub2> </child></root>\[/code\]As you can see, their childs have different sizes and i don't know how I can split a file like this in an efficient way in several parts.Can anyone give me a clue ?Best regards.
 
Back
Top