views:

37

answers:

1

I'm looking to store an entire book on an iPhone. I wanted to make the book searchable - it's a reference text. I'm also looking to break the book into chapters, or sections, etc. so that I can add a Table of Contents that the user can browse, and click to go straight to a particular chapter.

  • At first I thought about using SQLite to make it easy to categorize and divide into sections. But I must have been drunk or high, because the more I think about it the less it makes sense. Would there be any reason to use SQLite to store a book?

  • My alternative seems to be to just take the whole text file as it is now, and just parse it the best I can. Would this be a good approach? Chapters are usually headed by a decimal number X.XX so I could probably look for those by themselves.

In terms of runtime performance, how could I optimize the speed and memory usage when dealing with a book that is about 2MB in size?

A: 

As far as organizing the content of a book in a parsable format, you might want to look at the DocBook XML Schema.

codelark
Thanks. It looks to be potentially overkill, but I've used this as inspiration to write a converter to convert my original mess of text into an xml document that can be more easily parsed and dealt with.
liutenantdan