Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Building document tree with cross-over tags
- Abe Simpson
August 23, 2006, 3:58 pm
rate this thread
I am developing an HTML rendering app and now working on CSS implementation.
I understand I need to build a document tree to be able to correctly
implement CSS inheritance and contextual selectors. Now, a document
ABC <B> DEF <I> GHI </i> KLM </B> NOP
tranlates into a simple nice tree as every tag has a matching closing tag
and there are no crossovers. But what do you do with something like this :
ABC <B> DEF <I> GHI </B> KLM </I> NOP
Note that the closing B tag is encounted before a closing I tag. This is
still perfectly legal HTML, but how do you build a free out of that?
Thanks in advance.
- Beauregard T. Shagnasty
August 23, 2006, 4:56 pm
Re: Building document tree with cross-over tags
Personally, I'd just reject bad markup. If you must accept it, copy what the
main browsers do (you can use Mozilla's DOM inspector to see how they parse
TagSoup (http://home.ccil.org/~cowan/XML/tagsoup /) is a good parser for bad
markup - maybe you can use that?