Search in sources :

Example 1 with XmlTreeBuilder

use of org.jsoup.parser.XmlTreeBuilder in project jsoup by jhy.

the class UrlConnectTest method fetchHandlesXml.

@Test
public void fetchHandlesXml() throws IOException {
    // should auto-detect xml and use XML parser, unless explicitly requested the html parser
    String xmlUrl = "http://direct.infohound.net/tools/parse-xml.xml";
    Connection con = Jsoup.connect(xmlUrl);
    Document doc = con.get();
    Connection.Request req = con.request();
    assertTrue(req.parser().getTreeBuilder() instanceof XmlTreeBuilder);
    assertEquals("<xml> <link> one </link> <table> Two </table> </xml>", StringUtil.normaliseWhitespace(doc.outerHtml()));
}
Also used : Connection(org.jsoup.Connection) Document(org.jsoup.nodes.Document) XmlTreeBuilder(org.jsoup.parser.XmlTreeBuilder) Test(org.junit.Test)

Aggregations

Connection (org.jsoup.Connection)1 Document (org.jsoup.nodes.Document)1 XmlTreeBuilder (org.jsoup.parser.XmlTreeBuilder)1 Test (org.junit.Test)1