iPhone parse xhtml + css

passion_club

New Member
I have a complex long XHTML file, which contains CSS. Searching on google and on this site, I've found some libraries that can be useful on XHTML parsing:
  • NSXMLParser
  • TBXML
  • And some others
However, I'm wondering if there is any library for iPhone that can convert a xhtml + css document to a \[code\]NSAttributedString\[/code\] (only the text, of course). I have been thinking on that problem, and I have had some ideas, but I think it won't be very efficient. My main idea is formed by this steps:
  • Detect on the XTHML file all tags with an \[code\]id\[/code\] or \[code\]class\[/code\] attribute and get the range of the string where they have effect (I cannot achieve this).
  • Save all the CSS attributes on a \[code\]NSDictionary\[/code\], with more \[code\]NSDictionary\[/code\] objects inside. Something like this:\[code\]mainDict { object: dictionary { object: @"#00ff00" key: @"color" object: @"1em" key: @"font-size" } key: @"a id" object: anotherDictionary { ... } key: @"another id"}\[/code\]
  • Convert these CSS attributes dictionary on the \[code\]NSAttributedString\[/code\]attributes dictionary.
I know that this is complex, and I don't need you to provide the code (of course, if you provide it, it would be great), I only want the link to a library or, if it doesn't exist, some advice for create a parser myself.Of course, if you need some more information, ask by comments.Thanks you!!
 
Top