title: Jsoup check if string is valid HTML
body: <p>I am having difficulties with Jsoup parser. How can I tell if given string is a valid HTML code?</p>
  
  <pre><code>String input = "Your vote was successfully added."
  boolean isValid = Jsoup.isValid(input);
  // isValid = true
  </code></pre>
  
  <p>isValid flag is true, because Jsoup first uses HtmlTreeBuilder: if ony of html, head or body tag is missing, it adds them by itself. Then it uses Cleaner class and checks it against given Whitelist. </p>
  
  <p>Is there any simple way to check if string is a valid HTML without Jsoup attempts to make it HTML?</p>
  
  <p>My example is AJAX response, which comes as "text/html" content type. Then it goes to parser, Jsoup adds this tags and as a result, response is not displayed properly.</p>
  
  <p>Thanks for your help.</p>