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.