title: Checking HTML document with REST Assured
body: <p>I'm trying to use <a href="https://github.com/jayway/rest-assured" rel="noreferrer">REST Assured</a> to check some properties on an HTML document returned by my server. An <a href="http://sscce.org/" rel="noreferrer">SSCCE</a> demonstrating the problem would be as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>import static com.jayway.restassured.path.xml.config.XmlPathConfig.xmlPathConfig;
  import static org.hamcrest.CoreMatchers.is;
  import static org.junit.Assert.assertThat;
  
  import org.junit.Test;
  
  import com.jayway.restassured.path.xml.XmlPath;
  
  public class HtmlDocumentTest {
  
    @Test
    public void titleShouldBeHelloWorld() {
      final XmlPath xml = new XmlPath("&lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"&gt;"
        + "&lt;html xmlns=\"http://www.w3.org/1999/xhtml\"&gt;"
        + "&lt;head&gt;&lt;title&gt;Hello world&lt;/title&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;")
        .using(xmlPathConfig().with().feature("http://apache.org/xml/features/disallow-doctype-decl", false));
      assertThat(xml.get("//title[text()]"), is("Hello world"));
    }
  }
  </code></pre>
  
  <p>Now, this attempt ends in <code>com.jayway.restassured.path.xml.exception.XmlPathException: Failed to parse the XML document</code> caused by, off all the possible errors, <code>java.net.ConnectException: Connection timed out</code> after some 30 seconds or so!</p>
  
  <p>If I remove the line with the <code>xmlPathConfig().with().feature(...)</code> the test fails immediately due to <code>DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.</code>. </p>
  
  <p>If I remove the doctype line from the document the parsing succeeds but the test fails on an assertion error, "<code>Expected: is "Hello world" but: was &lt;Hello worldnull&gt;</code>" -- however, that's a different problem, obviously (but feel free to give instructions on that one, too...). And removing the doctype isn't an option for me anyway.</p>
  
  <p>So, question: how do you check properties of an HTML document with a doctype using REST Assured? It says <a href="https://code.google.com/p/rest-assured/wiki/Usage#Custom_parsers" rel="noreferrer">in the documentation</a> that "<em>REST Assured providers predefined parsers for e.g. HTML, XML and JSON.</em>", but I cannot seem to find any examples on how exactly to activate and work with that HTML parser! There's no "<code>HtmlPath</code>" class like there's <code>XmlPath</code>, for example, and that timeout exception is very puzzling...</p>