Package org.jsoup.parser
Class XmlTreeBuilder
java.lang.Object
org.jsoup.parser.TreeBuilder
org.jsoup.parser.XmlTreeBuilder
Use the
XmlTreeBuilder when you want to parse XML without any of the HTML DOM rules being applied to the
document.
Usage example: Document xmlDoc = Jsoup.parse(html, baseUrl, Parser.xmlParser());
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final ArrayDeque<HashMap<String, String>> (package private) static final String(package private) static final StringFields inherited from class org.jsoup.parser.TreeBuilder
baseUri, currentToken, doc, nodeListener, parser, reader, settings, stack, tagSet, tokeniser, trackSourceRange -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidapplyNamespacesToAttributes(Attributes attributes, HashMap<String, String> namespaces) (package private) intDefault maximum depth for parsers using this tree builder.Gets the default namespace for this TreeBuilder(package private) ParseSettings(package private) TagSetprotected voidinitialiseParse(Reader input, String baseUri, Parser parser) (package private) voidinitialiseParseFragment(Element context) (package private) void(package private) voidinsertCommentFor(Token.Comment commentToken) (package private) voidinsertDoctypeFor(Token.Doctype token) (package private) voidinsertElementFor(Token.StartTag startTag) (package private) voidinsertLeafNode(LeafNode node) (package private) void(package private) XmlTreeBuilderCreate a new copy of this TreeBuilder(package private) Document(package private) Document(package private) Elementpop()Removes the last Element from the stack, hits onNodeClosed, and then returns it.protected voidpopStackToClose(Token.EndTag endTag) If the stack contains an element with this tag's name, pop up the stack to remove the first occurrence.protected booleanprivate static voidprocessNamespaces(Attributes attributes, HashMap<String, String> namespaces) private static StringresolveNamespace(String tagName, HashMap<String, String> namespaces) Methods inherited from class org.jsoup.parser.TreeBuilder
completeParse, currentElement, currentElementIs, currentElementIs, enforceStackDepthLimit, error, error, nodeListener, onNodeClosed, onNodeInserted, onStackPrunedForDepth, parse, parseFragment, processEndTag, processStartTag, processStartTag, push, runParser, stepParser, tagFor, tagFor, trackNodePosition
-
Field Details
-
XmlnsKey
- See Also:
-
XmlnsPrefix
- See Also:
-
namespacesStack
-
maxQueueDepth
private static final int maxQueueDepth- See Also:
-
-
Constructor Details
-
XmlTreeBuilder
public XmlTreeBuilder()
-
-
Method Details
-
defaultSettings
ParseSettings defaultSettings()- Specified by:
defaultSettingsin classTreeBuilder
-
initialiseParse
- Overrides:
initialiseParsein classTreeBuilder
-
initialiseParseFragment
- Overrides:
initialiseParseFragmentin classTreeBuilder
-
parse
-
parse
-
completeParseFragment
- Specified by:
completeParseFragmentin classTreeBuilder
-
newInstance
XmlTreeBuilder newInstance()Description copied from class:TreeBuilderCreate a new copy of this TreeBuilder- Specified by:
newInstancein classTreeBuilder- Returns:
- copy, ready for a new parse
-
defaultNamespace
Description copied from class:TreeBuilderGets the default namespace for this TreeBuilder- Overrides:
defaultNamespacein classTreeBuilder- Returns:
- the default namespace
-
defaultTagSet
TagSet defaultTagSet()- Overrides:
defaultTagSetin classTreeBuilder
-
defaultMaxDepth
int defaultMaxDepth()Description copied from class:TreeBuilderDefault maximum depth for parsers using this tree builder.- Overrides:
defaultMaxDepthin classTreeBuilder
-
process
- Specified by:
processin classTreeBuilder
-
insertElementFor
-
processNamespaces
-
applyNamespacesToAttributes
private static void applyNamespacesToAttributes(Attributes attributes, HashMap<String, String> namespaces) -
resolveNamespace
-
insertLeafNode
-
insertCommentFor
-
insertCharacterFor
-
insertDoctypeFor
-
insertXmlDeclarationFor
-
pop
Element pop()Description copied from class:TreeBuilderRemoves the last Element from the stack, hits onNodeClosed, and then returns it.- Overrides:
popin classTreeBuilder- Returns:
-
popStackToClose
If the stack contains an element with this tag's name, pop up the stack to remove the first occurrence. If not found, skips.- Parameters:
endTag- tag to close
-