View Single Post
Old 06-07-2003, 03:00 PM   PM User |
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enough
Well, you have a very important difference between HTML4 and XHTML here. Have a look at this code:
Code:
Grandparent
<p>Parent
<p>Child
<p>Grandchild
</p>
Child
</p>
Parent
</p>
Grandparent
This is invalid, of course, but here's how an XML or XHTML parser would parse it:
>#text:Grandparent
>p
>p>#text:Parent
>p>p
>p>p>#text:Child
>p>p>p
>p>p>p>#text:Grandchild
>p>p>/p
>p>p>#text:Child
>p>/p
>p>#text:Parent
>/p
>#text:Grandparent


And here is how an SGML/HTML parser would parse it:
>#text:Grandparent
>p
>p>#text:Parent
>/p
>p
>p>#text:Child
>/p
>p
>p>#text:Grandchild
>/p
>#text:Child
>/p
>#text:Parent
>/p
>#text:Grandparent


There is a possibility that a badly written HTML parser would make the parsing that an XML parser does, but that would be a very erratic parser, because it SHOULD know to close the p tag before it opens any block element.
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote