
: EPub 3: Finding the Navigation document I've been looking at a few different ePub3s (programatically, not through ePub-specific software), and notive that the navigation document containing the TOC
I've been looking at a few different ePub3s (programatically, not through ePub-specific software), and notive that the navigation document containing the TOC doesn't seem to be constantly named.
Is there a way of finding it, other than through reading each file for the relevant HTML?
Thanks
Edit: Digging around further, perhaps the package.opf is the answer: <item id="nav_1" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"></item>?
Free books android app tbrJar TBR JAR Read Free books online gutenberg
More posts by @Ashley

: Are DRM location sensitive? It is quite frequent that a book available for sale in North America is not available in Europe, and conversely. However, it is quite legal to buy a book on one

: Can Kindle books handle side-by-side texts? In the realm of bilingual print books, there are many "side-by-side" story books in which one page tells a story in one language, and the facing page
1 Comments
Sorted by latest first Latest Oldest Best
I'll post an answer which seems to be working for me.
I found relevant documentation here: www.idpf.org/epub/30/spec/epub30-publications.html#sec-package-documents
Using Ruby and Nokogiri, I decompressed the ePub file, read the package document as HTML, then used an XPath statement:
unzipped_file = Zip::File.open(epub_file)
package_file = unzipped_file.glob("*/package.opf").first
package_as_html = Nokogiri::HTML(package_file.get_input_stream.read)
package = package_as_html.at_xpath("html/body/package")
nav_file_name = package.
at_xpath("manifest/item[@properties='nav']").
attribute("href").
text
Free books android app tbrJar TBR JAR Read Free books online gutenberg