title: How to validate html5 document against given structure?
body: <p>I have html5 document and I want to check its structure against some my own definition (similiar to xml file and XML Schema). Is there a way to do that except of some ugly manual parsing? Since HTML5 is not XML-friendly (not all tags have to be closed etc.) , I can't use DTD/XML Schema (or RelaxNG which I don't know) to do that, right? </p>
  
  <p>Are there any schema languages or maybe even validators (like Saxon engine...)? Javascript/jQuery implementation would be best.</p>
  
  <p>Sample:
  - Rule: all  must be inside  or  elements - not sure which "language" to use to describe it more formally...</p>
  
  <ul>
  <li><p>invalid file:</p>
  
  <p>&lt;!doctype html&gt;
  ...
  &lt;div&gt;&lt;a&gt;Invalid Link position&lt;a&gt;...</p></li>
  <li><p>valid file:</p>
  
  <p>&lt;!doctype html&gt;
  ...
  &lt;div&gt;&lt;table&gt;&lt;tr&gt;&lt;td>&lt;a&gt;Valid Link position&lt;a&gt;... </p></li>
  </ul>