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());
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classTracks namespace binding changes within element scopes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int(package private) final ArrayDeque<XmlTreeBuilder.NamespaceChange> private static final XmlTreeBuilder.NamespaceChange(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 voidapplyNamespaceDeclarations(Attributes attributes) Applies namespace declarations and records changes within an element scope.private voidapplyNamespacesToAttributes(Attributes attributes) Applies resolved namespace URIs to prefixed attributes.(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 StringresolveNamespace(String tagName) Resolves the namespace URI for a qualified tag name.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:
-
ScopeMarker
-
namespaceBindings
-
namespaceChanges
-
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
-
applyNamespaceDeclarations
Applies namespace declarations and records changes within an element scope. -
applyNamespacesToAttributes
Applies resolved namespace URIs to prefixed attributes. -
resolveNamespace
Resolves the namespace URI for a qualified tag name. -
pop
Element pop()Description copied from class:TreeBuilderRemoves the last Element from the stack, hits onNodeClosed, and then returns it.- Overrides:
popin classTreeBuilder- Returns:
-
insertLeafNode
-
insertCommentFor
-
insertCharacterFor
-
insertDoctypeFor
-
insertXmlDeclarationFor
-
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
-