Modifier and Type | Field and Description |
---|---|
private static int |
DEFAULT_MAX_ERRORS |
private ParseErrorList |
errors |
private int |
maxErrors |
private ParseSettings |
settings |
private TreeBuilder |
treeBuilder |
Constructor and Description |
---|
Parser(TreeBuilder treeBuilder)
Create a new Parser, using the specified TreeBuilder
|
Modifier and Type | Method and Description |
---|---|
List<ParseError> |
getErrors()
Retrieve the parse errors, if any, from the last parse.
|
TreeBuilder |
getTreeBuilder()
Get the TreeBuilder currently in use.
|
static Parser |
htmlParser()
Create a new HTML parser.
|
boolean |
isTrackErrors()
Check if parse error tracking is enabled.
|
static Document |
parse(String html,
String baseUri)
Parse HTML into a Document.
|
static Document |
parseBodyFragment(String bodyHtml,
String baseUri)
Parse a fragment of HTML into the
body of a Document. |
static Document |
parseBodyFragmentRelaxed(String bodyHtml,
String baseUri)
|
static List<Node> |
parseFragment(String fragmentHtml,
Element context,
String baseUri)
Parse a fragment of HTML into a list of nodes.
|
static List<Node> |
parseFragment(String fragmentHtml,
Element context,
String baseUri,
ParseErrorList errorList)
Parse a fragment of HTML into a list of nodes.
|
Document |
parseInput(Reader inputHtml,
String baseUri) |
Document |
parseInput(String html,
String baseUri) |
static List<Node> |
parseXmlFragment(String fragmentXml,
String baseUri)
Parse a fragment of XML into a list of nodes.
|
ParseSettings |
settings() |
Parser |
settings(ParseSettings settings) |
Parser |
setTrackErrors(int maxErrors)
Enable or disable parse error tracking for the next parse.
|
Parser |
setTreeBuilder(TreeBuilder treeBuilder)
Update the TreeBuilder used when parsing content.
|
static String |
unescapeEntities(String string,
boolean inAttribute)
Utility method to unescape HTML entities from a string
|
static Parser |
xmlParser()
Create a new XML parser.
|
private static final int DEFAULT_MAX_ERRORS
private TreeBuilder treeBuilder
private int maxErrors
private ParseErrorList errors
private ParseSettings settings
public Parser(TreeBuilder treeBuilder)
treeBuilder
- TreeBuilder to use to parse input into Documents.public Document parseInput(String html, String baseUri)
public Document parseInput(Reader inputHtml, String baseUri)
public TreeBuilder getTreeBuilder()
public Parser setTreeBuilder(TreeBuilder treeBuilder)
treeBuilder
- current TreeBuilderpublic boolean isTrackErrors()
public Parser setTrackErrors(int maxErrors)
maxErrors
- the maximum number of errors to track. Set to 0 to disable.public List<ParseError> getErrors()
public Parser settings(ParseSettings settings)
public ParseSettings settings()
public static Document parse(String html, String baseUri)
html
- HTML to parsebaseUri
- base URI of document (i.e. original fetch location), for resolving relative URLs.public static List<Node> parseFragment(String fragmentHtml, Element context, String baseUri)
fragmentHtml
- the fragment of HTML to parsecontext
- (optional) the element that this HTML fragment is being parsed for (i.e. for inner HTML). This
provides stack context (for implicit element creation).baseUri
- base URI of document (i.e. original fetch location), for resolving relative URLs.public static List<Node> parseFragment(String fragmentHtml, Element context, String baseUri, ParseErrorList errorList)
fragmentHtml
- the fragment of HTML to parsecontext
- (optional) the element that this HTML fragment is being parsed for (i.e. for inner HTML). This
provides stack context (for implicit element creation).baseUri
- base URI of document (i.e. original fetch location), for resolving relative URLs.errorList
- list to add errors topublic static List<Node> parseXmlFragment(String fragmentXml, String baseUri)
fragmentXml
- the fragment of XML to parsebaseUri
- base URI of document (i.e. original fetch location), for resolving relative URLs.public static Document parseBodyFragment(String bodyHtml, String baseUri)
body
of a Document.bodyHtml
- fragment of HTMLbaseUri
- base URI of document (i.e. original fetch location), for resolving relative URLs.public static String unescapeEntities(String string, boolean inAttribute)
string
- HTML escaped stringinAttribute
- if the string is to be escaped in strict mode (as attributes are)public static Document parseBodyFragmentRelaxed(String bodyHtml, String baseUri)
parseBodyFragment(java.lang.String, java.lang.String)
or parseFragment(java.lang.String, org.jsoup.nodes.Element, java.lang.String)
instead.bodyHtml
- HTML to parsebaseUri
- baseUri base URI of document (i.e. original fetch location), for resolving relative URLs.public static Parser htmlParser()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses