org.jsoup.nodes
Class Document

java.lang.Object
  extended by org.jsoup.nodes.Node
      extended by org.jsoup.nodes.Element
          extended by org.jsoup.nodes.Document
All Implemented Interfaces:
Cloneable

public class Document
extends Element

A HTML Document.

Author:
Jonathan Hedley, [email protected]

Nested Class Summary
static class Document.OutputSettings
          A Document's output settings control the form of the text() and html() methods.
static class Document.QuirksMode
           
 
Constructor Summary
Document(String baseUri)
          Create a new, empty Document.
 
Method Summary
 Element body()
          Accessor to the document's body element.
 Document clone()
          Create a stand-alone, deep copy of this node, and all of its children.
 Element createElement(String tagName)
          Create a new Element, with this document's base uri.
static Document createShell(String baseUri)
          Create a valid, empty shell of a document, suitable for adding more elements to.
 Element head()
          Accessor to the document's head element.
 String nodeName()
          Get the node name of this node.
 Document normalise()
          Normalise the document.
 String outerHtml()
          Get the outer HTML of this node.
 Document.OutputSettings outputSettings()
          Get the document's current output settings.
 Document.QuirksMode quirksMode()
           
 Document quirksMode(Document.QuirksMode quirksMode)
           
 Element text(String text)
          Set the text of the body of this document.
 String title()
          Get the string contents of the document's title element.
 void title(String title)
          Set the document's title element.
 
Methods inherited from class org.jsoup.nodes.Element
addClass, after, after, append, appendChild, appendElement, appendText, attr, before, before, child, children, className, classNames, classNames, data, dataset, elementSiblingIndex, empty, equals, firstElementSibling, getAllElements, getElementById, getElementsByAttribute, getElementsByAttributeStarting, getElementsByAttributeValue, getElementsByAttributeValueContaining, getElementsByAttributeValueEnding, getElementsByAttributeValueMatching, getElementsByAttributeValueMatching, getElementsByAttributeValueNot, getElementsByAttributeValueStarting, getElementsByClass, getElementsByIndexEquals, getElementsByIndexGreaterThan, getElementsByIndexLessThan, getElementsByTag, getElementsContainingOwnText, getElementsContainingText, getElementsMatchingOwnText, getElementsMatchingOwnText, getElementsMatchingText, getElementsMatchingText, hasClass, hashCode, hasText, html, html, id, isBlock, lastElementSibling, nextElementSibling, ownText, parent, parents, prepend, prependChild, prependElement, prependText, previousElementSibling, removeClass, select, siblingElements, tag, tagName, tagName, text, toggleClass, toString, val, val, wrap
 
Methods inherited from class org.jsoup.nodes.Node
absUrl, addChildren, addChildren, attr, attributes, baseUri, childNode, childNodes, childNodesAsArray, doClone, hasAttr, indent, nextSibling, outerHtml, ownerDocument, previousSibling, remove, removeAttr, removeChild, replaceChild, replaceWith, setBaseUri, setParentNode, setSiblingIndex, siblingIndex, siblingNodes, unwrap
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Document

public Document(String baseUri)
Create a new, empty Document.

Parameters:
baseUri - base URI of document
See Also:
Jsoup.parse(java.lang.String, java.lang.String), createShell(java.lang.String)
Method Detail

createShell

public static Document createShell(String baseUri)
Create a valid, empty shell of a document, suitable for adding more elements to.

Parameters:
baseUri - baseUri of document
Returns:
document with html, head, and body elements.

head

public Element head()
Accessor to the document's head element.

Returns:
head

body

public Element body()
Accessor to the document's body element.

Returns:
body

title

public String title()
Get the string contents of the document's title element.

Returns:
Trimed title, or empty string if none set.

title

public void title(String title)
Set the document's title element. Updates the existing element, or adds title to head if not present

Parameters:
title - string to set as title

createElement

public Element createElement(String tagName)
Create a new Element, with this document's base uri. Does not make the new element a child of this document.

Parameters:
tagName - element tag name (e.g. a)
Returns:
new element

normalise

public Document normalise()
Normalise the document. This happens after the parse phase so generally does not need to be called. Moves any text content that is not in the body element into the body.

Returns:
this document after normalisation

outerHtml

public String outerHtml()
Description copied from class: Node
Get the outer HTML of this node.

Overrides:
outerHtml in class Node
Returns:
HTML

text

public Element text(String text)
Set the text of the body of this document. Any existing nodes within the body will be cleared.

Overrides:
text in class Element
Parameters:
text - unencoded text
Returns:
this document

nodeName

public String nodeName()
Description copied from class: Node
Get the node name of this node. Use for debugging purposes and not logic switching (for that, use instanceof).

Overrides:
nodeName in class Element
Returns:
node name

clone

public Document clone()
Description copied from class: Node
Create a stand-alone, deep copy of this node, and all of its children. The cloned node will have no siblings or parent node. As a stand-alone object, any changes made to the clone or any of its children will not impact the original node.

The cloned node may be adopted into another Document or node structure using Element.appendChild(Node).

Overrides:
clone in class Element
Returns:
stand-alone cloned node

outputSettings

public Document.OutputSettings outputSettings()
Get the document's current output settings.

Returns:
the document's current output settings.

quirksMode

public Document.QuirksMode quirksMode()

quirksMode

public Document quirksMode(Document.QuirksMode quirksMode)


Copyright © 2009-2011 Jonathan Hedley. All Rights Reserved.