# DocumentBuilder

public abstract class **DocumentBuilder** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
Defines the API to obtain DOM Document instances from an XML
document. Using this class, an application programmer can obtain a
`https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` from XML.


An instance of this class can be obtained from the
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilderFactory.html#newDocumentBuilder()` method. Once
an instance of this class is obtained, XML can be parsed from a
variety of input sources. These input sources are InputStreams,
Files, URLs, and SAX InputSources.


Note that this class reuses several classes from the SAX API. This
does not require that the implementor of the underlying DOM
implementation use a SAX parser to parse XML document into a
`Document`. It merely requires that the implementation
communicate with the application using these existing APIs.

### Protected Constructor Summary

|---|---|
|   | [DocumentBuilder](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#DocumentBuilder())() Protected constructor |

### Public Method Summary

|---|---|
| abstract [DOMImplementation](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/DOMImplementation.html) | [getDOMImplementation](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#getDOMImplementation())() Obtain an instance of a `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/DOMImplementation.html` object. |
| [Schema](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Schema.html) | [getSchema](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#getSchema())() Get a reference to the the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Schema.html` being used by the XML processor. |
| abstract boolean | [isNamespaceAware](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#isNamespaceAware())() Indicates whether or not this parser is configured to understand namespaces. |
| abstract boolean | [isValidating](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#isValidating())() Indicates whether or not this parser is configured to validate XML documents. |
| boolean | [isXIncludeAware](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#isXIncludeAware())() Get the XInclude processing mode for this parser. |
| abstract [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html) | [newDocument](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#newDocument())() Obtain a new instance of a DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object to build a DOM tree with. |
| abstract [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html) | [parse](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#parse(org.xml.sax.InputSource))([InputSource](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/InputSource.html) is) Parse the content of the given input source as an XML document and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object. |
| [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html) | [parse](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#parse(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) uri) Parse the content of the given URI as an XML document and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object. |
| [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html) | [parse](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#parse(java.io.InputStream))([InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) is) Parse the content of the given `InputStream` as an XML document and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object. |
| [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html) | [parse](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#parse(java.io.InputStream,%20java.lang.String))([InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) is, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) systemId) Parse the content of the given `InputStream` as an XML document and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object. |
| [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html) | [parse](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#parse(java.io.File))([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) f) Parse the content of the given file as an XML document and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object. |
| void | [reset](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#reset())() Reset this `DocumentBuilder` to its original configuration. |
| abstract void | [setEntityResolver](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#setEntityResolver(org.xml.sax.EntityResolver))([EntityResolver](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/EntityResolver.html) er) Specify the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/EntityResolver.html` to be used to resolve entities present in the XML document to be parsed. |
| abstract void | [setErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilder.html#setErrorHandler(org.xml.sax.ErrorHandler))([ErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html) eh) Specify the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` to be used by the parser. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Protected Constructors

#### protected
**DocumentBuilder**
()

Protected constructor

## Public Methods

#### public abstract [DOMImplementation](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/DOMImplementation.html)
**getDOMImplementation**
()

Obtain an instance of a `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/DOMImplementation.html` object.

##### Returns

- A new instance of a `DOMImplementation`.

#### public [Schema](https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Schema.html)
**getSchema**
()

<br />

Get a reference to the the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Schema.html` being used by
the XML processor.

If no schema is being used, `null` is returned.

<br />

##### Returns

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/validation/Schema.html` being used or `null` if none in use

##### Throws

| [UnsupportedOperationException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/UnsupportedOperationException.html) | For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |
|---|---|

#### public abstract boolean
**isNamespaceAware**
()

Indicates whether or not this parser is configured to
understand namespaces.

##### Returns

- true if this parser is configured to understand namespaces; false otherwise.

#### public abstract boolean
**isValidating**
()

Indicates whether or not this parser is configured to
validate XML documents.

##### Returns

- true if this parser is configured to validate XML documents; false otherwise.

#### public boolean
**isXIncludeAware**
()

<br />

Get the XInclude processing mode for this parser.

<br />

##### Returns

- the return value of the `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilderFactory.html#isXIncludeAware()` when this parser was created from factory.

##### Throws

| [UnsupportedOperationException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/UnsupportedOperationException.html) | For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilderFactory.html#setXIncludeAware(boolean)`

#### public abstract [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html)
**newDocument**
()

Obtain a new instance of a DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object
to build a DOM tree with.

##### Returns

- A new instance of a DOM Document object.

#### public abstract [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html)
**parse**
([InputSource](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/InputSource.html) is)

Parse the content of the given input source as an XML document
and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object.
An `IllegalArgumentException` is thrown if the
`InputSource` is `null` null.

##### Parameters

| is | InputSource containing the content to be parsed. |
|---|---|

##### Returns

- A new DOM Document object.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If any IO errors occur. |
| [SAXException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html) | If any parse errors occur. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/DocumentHandler.html`

#### public [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html)
**parse**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) uri)

Parse the content of the given URI as an XML document
and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object.
An `IllegalArgumentException` is thrown if the
URI is `null` null.

##### Parameters

| uri | The location of the content to be parsed. |
|---|---|

##### Returns

- A new DOM Document object.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If any IO errors occur. |
| [SAXException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html) | If any parse errors occur. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/DocumentHandler.html`

#### public [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html)
**parse**
([InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) is)

Parse the content of the given `InputStream` as an XML
document and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object.
An `IllegalArgumentException` is thrown if the
`InputStream` is null.

##### Parameters

| is | InputStream containing the content to be parsed. |
|---|---|

##### Returns

- `Document` result of parsing the `InputStream`

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If any IO errors occur. |
| [SAXException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html) | If any parse errors occur. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/DocumentHandler.html`

#### public [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html)
**parse**
([InputStream](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/InputStream.html) is, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) systemId)

Parse the content of the given `InputStream` as an
XML document and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object.
An `IllegalArgumentException` is thrown if the
`InputStream` is null.

##### Parameters

| is | InputStream containing the content to be parsed. |
| systemId | Provide a base for resolving relative URIs. |
|---|---|

##### Returns

- A new DOM Document object.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If any IO errors occur. |
| [SAXException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html) | If any parse errors occur. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/DocumentHandler.html`

#### public [Document](https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html)
**parse**
([File](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/File.html) f)

Parse the content of the given file as an XML document
and return a new DOM `https://developers.google.com/j2objc/javadoc/jre/reference/org/w3c/dom/Document.html` object.
An `IllegalArgumentException` is thrown if the
`File` is `null` null.

##### Parameters

| f | The file containing the XML to parse. |
|---|---|

##### Returns

- A new DOM Document object.

##### Throws

| [IOException](https://developers.google.com/j2objc/javadoc/jre/reference/java/io/IOException.html) | If any IO errors occur. |
| [SAXException](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/SAXException.html) | If any parse errors occur. |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/DocumentHandler.html`

#### public void
**reset**
()

<br />

Reset this `DocumentBuilder` to its original configuration.

`DocumentBuilder` is reset to the same state as when it was created with
`https://developers.google.com/j2objc/javadoc/jre/reference/javax/xml/parsers/DocumentBuilderFactory.html#newDocumentBuilder()`.
`reset()` is designed to allow the reuse of existing `DocumentBuilder`s
thus saving resources associated with the creation of new `DocumentBuilder`s.

The reset `DocumentBuilder` is not guaranteed to have the same `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/EntityResolver.html` or `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html`
`Object`s, e.g. `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object)`. It is guaranteed to have a functionally equal
`EntityResolver` and `ErrorHandler`.

<br />

#### public abstract void
**setEntityResolver**
([EntityResolver](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/EntityResolver.html) er)

Specify the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/EntityResolver.html` to be used to resolve
entities present in the XML document to be parsed. Setting
this to `null` will result in the underlying
implementation using it's own default implementation and
behavior.

##### Parameters

| er | The `EntityResolver` to be used to resolve entities present in the XML document to be parsed. |
|---|---|

#### public abstract void
**setErrorHandler**
([ErrorHandler](https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html) eh)

Specify the `https://developers.google.com/j2objc/javadoc/jre/reference/org/xml/sax/ErrorHandler.html` to be used by the parser.
Setting this to `null` will result in the underlying
implementation using it's own default implementation and
behavior.

##### Parameters

| eh | The `ErrorHandler` to be used by the parser. |
|---|---|