Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ebook reader suggestions




On Jun 29, 2005, at 7:51 PM, Gary Yuen wrote:

If I have XHTML documents that let's say contained a whole chapter or even book, how would I go about displaying only chapters or sections? DOM? Can I get use DOM to selectively display only parts of XHTML? Any good docs to get started with this?


You can use the DOM APIs to extract a portion of a document--a range, say--and insert it into another document. So, for example, you could use one (not displayed) WebView to load and parse your document into a DOM, and then extract a portion of it and insert it into another (displayed) WebView to show an individual section of the document.


An alternative approach would be to convert the document to an attributed string, using the text system's ability to import HTML. This is not completely faithful, since attributed strings cannot represent all of the features of HTML, but it may be sufficient for your purposes, and extracting substrings from attributed strings is more straightforward and less problematic than similar operations on a DOM.

Douglas Davidson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >ebook reader suggestions (From: Gary Yuen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.