public class Parser extends Object
| 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.
|
Document |
parseInput(String html, String baseUri) |
static List<Node> |
parseXmlFragment(String fragmentXml, String baseUri)
Parse a fragment of XML into a list of nodes.
|
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.
|
public Parser(TreeBuilder treeBuilder)
treeBuilder - TreeBuilder to use to parse input into Documents.
public TreeBuilder getTreeBuilder()
public Parser setTreeBuilder(TreeBuilder treeBuilder)
treeBuilder - current TreeBuilder
public 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 static Document parse(String html, String baseUri)
html - HTML to parse
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)
fragmentHtml - the fragment of HTML to parse
context - (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> parseXmlFragment(String fragmentXml, String baseUri)
fragmentXml - the fragment of XML to parse
baseUri - 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 HTML
baseUri - base URI of document (i.e. original fetch location), for resolving relative URLs.
public static String unescapeEntities(String string, boolean inAttribute)
string - HTML escaped string
inAttribute - 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 parse
baseUri - baseUri base URI of document (i.e. original fetch location), for resolving relative URLs.
public static Parser htmlParser()
public static Parser xmlParser()
Copyright © 1998–2019 iText Group NV. All rights reserved.