Search code examples
javaandroidfile-ioinputstreamfileinputstream

java inputStream read large html only one tag at a time


I have an android app that works with large html files (a whole book). Reading whole html files is not a good idea for many reasons (performance, memory usage, etc.)

I prefer to read the file one tag at a time if it's possible. My Html file looks like this

<main_tag>some text here</main_tag>
<main_tag><sub_tag>something</sub_tag><sub_tag>another thing</sub_tag><main_tag>

My Main tags are h1 ... h6 and p. And i want to read my file based on this tags. All the other tags are included in main tags and should be read with main tag.

any idea how can i achieve this? performance is a real issue here


Solution

  • all you need is to use android xml pull api, read the documentation about org.xmlpull.v1.XmlPullParser

    Nirav