Package org.jsoup.parser

## Class XmlTreeBuilder

- java.lang.Object
- - org.jsoup.parser.XmlTreeBuilder

    public class XmlTreeBuilder
    extends java.lang.Object

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());`

Author:
  Jonathan Hedley

### Field Summary

Fields
`protected java.lang.String` `baseUri`
`protected org.jsoup.parser.Token` `currentToken`
`protected Document` `doc`
`protected Parser` `parser`
`protected java.util.Map<java.lang.String,​Tag>` `seenTags`
`protected ParseSettings` `settings`
`protected java.util.ArrayList<Element>` `stack`

### Constructor Summary

Constructors
`XmlTreeBuilder()`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected Element` `currentElement()` Get the current element (last on the stack).
`protected boolean` `currentElementIs​(java.lang.String normalName)` Checks if the Current Element's normal name equals the supplied name.
`protected void` `error​(java.lang.String msg)` If the parser is tracking errors, add an error at the current position.
`protected void` `error​(java.lang.String msg, java.lang.Object... args)` If the parser is tracking errors, add an error at the current position.
`protected void` `initialiseParse​(java.io.Reader input, java.lang.String baseUri, Parser parser)`
`protected boolean` `isContentForTagData​(java.lang.String normalName)` (An internal method, visible for Element.
`protected boolean` `process​(org.jsoup.parser.Token token)`
`protected boolean` `processEndTag​(java.lang.String name)`
`protected boolean` `processStartTag​(java.lang.String name)`
`boolean` `processStartTag​(java.lang.String name, Attributes attrs)`
`protected void` `runParser()`
`protected Tag` `tagFor​(java.lang.String tagName, ParseSettings settings)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### parser

    protected Parser parser

#### doc

    protected Document doc

#### stack

    protected java.util.ArrayList<Element> stack

#### baseUri

    protected java.lang.String baseUri

#### currentToken

    protected org.jsoup.parser.Token currentToken

#### settings

    protected ParseSettings settings

#### seenTags

    protected java.util.Map<java.lang.String,​Tag> seenTags

### Constructor Detail

#### XmlTreeBuilder

    public XmlTreeBuilder()

### Method Detail

#### initialiseParse

    @ParametersAreNonnullByDefault
    protected void initialiseParse​(java.io.Reader input,
                                   java.lang.String baseUri,
                                   Parser parser)

#### process

    protected boolean process​(org.jsoup.parser.Token token)

#### runParser

    protected void runParser()

#### processStartTag

    protected boolean processStartTag​(java.lang.String name)

#### processStartTag

    public boolean processStartTag​(java.lang.String name,
                                   Attributes attrs)

#### processEndTag

    protected boolean processEndTag​(java.lang.String name)

#### currentElement

    protected Element currentElement()

Get the current element (last on the stack). If all items have been removed, returns the document instead (which might not actually be on the stack; use stack.size() == 0 to test if required.

Returns:
  the last element on the stack, if any; or the root document

#### currentElementIs

    protected boolean currentElementIs​(java.lang.String normalName)

Checks if the Current Element's normal name equals the supplied name.

Parameters:
  `normalName` - name to check
Returns:
  true if there is a current element on the stack, and its name equals the supplied

#### error

    protected void error​(java.lang.String msg)

If the parser is tracking errors, add an error at the current position.

Parameters:
  `msg` - error message

#### error

    protected void error​(java.lang.String msg,
                         java.lang.Object... args)

If the parser is tracking errors, add an error at the current position.

Parameters:
  `msg` - error message template
  `args` - template arguments

#### isContentForTagData

    protected boolean isContentForTagData​(java.lang.String normalName)

(An internal method, visible for Element. For HTML parse, signals that script and style text should be treated as Data Nodes).

#### tagFor

    protected Tag tagFor​(java.lang.String tagName,
                         ParseSettings settings)