src/main/java/org/jsoup/nodes/Document.java
return title;
String getTitle()
String title
src/main/java/org/jsoup/nodes/Document.java
this.title = title;
void setTitle(String title)
src/test/java/org/jsoup/parser/ParserTest.java
@Test public void parsesRoughAttributes() {
    @Test public void parsesComments() {

    @Test public void parsesUnterminatedComments() {
        String html = "<p>Hello<!-- <tr><td>";
        Document doc = Jsoup.parse(html);
        Element p = doc.getElementsByTag("p").get(0);
        assertEquals("Hello", p.text());
        TextNode text = (TextNode) p.childNode(0);
        assertEquals("Hello", text.getWholeText());
        Comment comment = (Comment) p.childNode(1);
        assertEquals(" <tr><td>", comment.getData());
void parsesSimpleDocument()
src/test/java/org/jsoup/parser/ParserTest.java
String h1 = "<p";
        Document doc = Jsoup.parse(h1);
        assertEquals(1, doc.getElementsByTag("p").size());

        String h2 = "<div id=1<p id='2'";
        doc = Jsoup.parse(h2);
        Element d = doc.getElementById("1");
        assertEquals(1, d.children().size());
        Element p = doc.getElementById("2");
        assertNotNull(p);
void parsesUnterminatedTag()
src/test/java/org/jsoup/parser/ParserTest.java
String h1 = "<p id=\"foo";
        Document doc = Jsoup.parse(h1);
        Element p = doc.getElementById("foo");
        assertNotNull(p);
        assertEquals("p", p.tagName());
void parsesUnterminatedAttribute()
src/test/java/org/jsoup/parser/ParserTest.java
String html = "<meta name=keywords /><link rel=stylesheet /><title>jsoup</title><p>Hello world</p>";
        Document doc = Jsoup.parse(html);
        Element head = doc.getHead();
        Element body = doc.getBody();

        assertEquals(2, doc.children().size());
        assertEquals(3, head.children().size());
        assertEquals(1, body.children().size());

        assertEquals("keywords", head.getElementsByTag("meta").get(0).attr("name"));
        assertEquals(0, body.getElementsByTag("meta").size());
        assertEquals("jsoup", doc.getTitle());
        assertEquals("Hello world", body.text());
        assertEquals("Hello world", body.children().get(0).text());
void createsDocumentStructure()
src/main/java/org/jsoup/parser/Parser.java
while (!matches("<")) {
            textAccum.append(consume());
    /**
     * Pulls a string off the queue, up to but exclusive of the match sequence, or to the queue running out.
     * @param seq String to end on (and not include in return, but leave on queue)
     * @return The matched data consumed from queue.
     */
    private String consumeTo(String seq) {
        StringBuilder accum = new StringBuilder();
        while (!queue.isEmpty() && !matches(seq))
            accum.append(consume());

        return accum.toString();
void parseText()
String seq
src/main/java/org/jsoup/parser/Parser.java
String data = consumeTo(seq);
        consume(seq);
        return data;
String chompTo(String seq)
src/main/java/org/jsoup/parser/Parser.java
return queue.removeFirst();
Character consume()
String seq
src/main/java/org/jsoup/parser/Parser.java
int len = seq.length();
        if (len > queue.size())
            throw new IllegalStateException("Queue not long enough to consume sequence");
        char[] seqChars = seq.toCharArray();
        for (int i = 0; i < len; i++) {
            Character qChar = consume();
            if (!qChar.equals(seqChars[i]))
                throw new IllegalStateException("Queue did not match expected sequence");
void consume(String seq)
src/main/java/org/jsoup/parser/Parser.java
while (Character.isWhitespace(queue.peekFirst())) {
            consume();
void consumeWhitespace()
src/main/java/org/jsoup/parser/Parser.java
StringBuilder wordAccum = new StringBuilder();
        while (Character.isLetterOrDigit(queue.peekFirst())) {
            wordAccum.append(queue.removeFirst());
String consumeWord()
String seq
src/main/java/org/jsoup/parser/Parser.java
int len = seq.length();
        if (len > queue.size())
            return false;
        List<Character> chars = queue.subList(0, len);
        char[] seqChars = seq.toCharArray();
        for (int i = 0; i < len; i++) {
            if (!chars.get(i).equals(seqChars[i]))
                return false;
boolean matches(String seq)