See the question and my original answer on StackOverflow

You can check there is a HEAD element or a BODY element under an HTML element like this for example:

bool hasHead = doc.DocumentNode.SelectSingleNode("html/head") != null;
bool hasBody = doc.DocumentNode.SelectSingleNode("html/body") != null;

These would fail if there is no HTML element, or if there is no BODY element under the HTML element.

Note I don't use this kind of XPATH expression "//head" because it would give a result even if the head was not directly under the HTML element.