public class Parser extends Object
Constructor and Description |
---|
Parser(org.jsoup.parser.TreeBuilder treeBuilder)
Create a new Parser, using the specified TreeBuilder
|
Modifier and Type | Method and Description |
---|---|
ParseErrorList |
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 |
isContentForTagData(String normalName)
(An internal method, visible for Element.
|
boolean |
isTrackErrors()
Check if parse error tracking is enabled.
|
Parser |
newInstance()
Creates a new Parser as a deep copy of this; including initializing a new TreeBuilder.
|
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 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.
|
List<Node> |
parseFragmentInput(String fragment,
Element context,
String baseUri) |
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 Parser newInstance()
public List<Node> parseFragmentInput(String fragment, Element context, String baseUri)
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 ParseErrorList getErrors()
public Parser settings(ParseSettings settings)
public ParseSettings settings()
public boolean isContentForTagData(String normalName)
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 Parser htmlParser()
public static Parser xmlParser()
Copyright © 2009–2021 Jonathan Hedley. All rights reserved.