public class Parser extends Object
Constructor | Description |
---|---|
Parser(org.jsoup.parser.TreeBuilder treeBuilder) |
Create a new Parser, using the specified TreeBuilder
|
Modifier and Type | Method | Description |
---|---|---|
List<ParseError> |
getErrors() |
Retrieve the parse errors, if any, from the last parse.
|
org.jsoup.parser.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(org.jsoup.parser.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.
|
public Parser(org.jsoup.parser.TreeBuilder treeBuilder)
treeBuilder
- TreeBuilder to use to parse input into Documents.public org.jsoup.parser.TreeBuilder getTreeBuilder()
public Parser setTreeBuilder(org.jsoup.parser.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()
public static Parser xmlParser()
Copyright © 2009–2017 Jonathan Hedley. All rights reserved.