title: check user inserted string is valid HTML or not
body: <p>I have one <code>textarea</code> for user to insert html using <code>tinymce</code>.
  And i am using <code>html2pdf</code> library to print that content in <code>PDF</code>.
  But, sometime user inserts invalid html like this,</p>
  
  <pre><code>&lt;p&gt;&lt;span&gt;test&lt;/p&gt;
  </code></pre>
  
  <p>So it cause the error while printing PDF.</p>
  
  <p>So what i want is to check before printing that if HTML is valid or not like this,</p>
  
  <pre><code>if(valid_html)
     PRINT_PDF
  else
     strip_tags(PRINT_PDF); // removing tags from sting
  </code></pre>
  
  <p>For that i tried this solution also from <a href="https://stackoverflow.com/questions/3167074/which-function-in-php-validate-if-the-string-is-valid-html">here</a>.
  But not working in many cases. I need solution for this to allow users to print pdf.</p>