Added in API level 1

DocumentBuilder

abstract class DocumentBuilder
kotlin.Any
   ↳ javax.xml.parsers.DocumentBuilder

Defines the API to obtain DOM Document instances from an XML document. Using this class, an application programmer can obtain a Document from XML.

An instance of this class can be obtained from the DocumentBuilderFactory.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.

Summary

Protected constructors

Protected constructor

Public methods
abstract DOMImplementation!

Obtain an instance of a DOMImplementation object.

open Schema!

Get a reference to the the Schema being used by the XML processor.

abstract Boolean

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

abstract Boolean

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

open Boolean

Get the XInclude processing mode for this parser.

abstract Document!

Obtain a new instance of a DOM Document object to build a DOM tree with.

open Document!
parse(f: File!)

Parse the content of the given file as an XML document and return a new DOM Document object.

open Document!

Parse the content of the given InputStream as an XML document and return a new DOM Document object.

open Document!
parse(is: InputStream!, systemId: String!)

Parse the content of the given InputStream as an XML document and return a new DOM Document object.

open Document!
parse(uri: String!)

Parse the content of the given URI as an XML document and return a new DOM Document object.

abstract Document!

Parse the content of the given input source as an XML document and return a new DOM Document object.

open Unit

Reset this DocumentBuilder.

abstract Unit

Specify the EntityResolver to be used to resolve entities present in the XML document to be parsed.

abstract Unit

Specify the ErrorHandler to be used by the parser.

Protected constructors

DocumentBuilder

Added in API level 1
protected DocumentBuilder()

Protected constructor

Public methods

getDOMImplementation

Added in API level 1
abstract fun getDOMImplementation(): DOMImplementation!

Obtain an instance of a DOMImplementation object.

Return
DOMImplementation! A new instance of a DOMImplementation.

getSchema

Added in API level 8
open fun getSchema(): Schema!

Get a reference to the the Schema being used by the XML processor.

If no schema is being used, null is returned.

Return
Schema! Schema being used or null if none in use
Exceptions
java.lang.UnsupportedOperationException For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown.

isNamespaceAware

Added in API level 1
abstract fun isNamespaceAware(): Boolean

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

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

isValidating

Added in API level 1
abstract fun isValidating(): Boolean

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

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

isXIncludeAware

Added in API level 1
open fun isXIncludeAware(): Boolean

Get the XInclude processing mode for this parser.

Return
Boolean the return value of the DocumentBuilderFactory.isXIncludeAware() when this parser was created from factory.
Exceptions
java.lang.UnsupportedOperationException For backward compatibility, when implementations for earlier versions of JAXP is used, this exception will be thrown.

newDocument

Added in API level 1
abstract fun newDocument(): Document!

Obtain a new instance of a DOM Document object to build a DOM tree with.

Return
Document! A new instance of a DOM Document object.

parse

Added in API level 1
open fun parse(f: File!): Document!

Parse the content of the given file as an XML document and return a new DOM Document object. An IllegalArgumentException is thrown if the File is null null.

Parameters
f File!: The file containing the XML to parse.
Return
Document! A new DOM Document object.
Exceptions
java.io.IOException If any IO errors occur.
org.xml.sax.SAXException If any parse errors occur.

parse

Added in API level 1
open fun parse(is: InputStream!): Document!

Parse the content of the given InputStream as an XML document and return a new DOM Document object. An IllegalArgumentException is thrown if the InputStream is null.

Parameters
is InputStream!: InputStream containing the content to be parsed.
Return
Document! Document result of parsing the InputStream
Exceptions
java.io.IOException If any IO errors occur.
org.xml.sax.SAXException If any parse errors occur.

parse

Added in API level 1
open fun parse(
    is: InputStream!,
    systemId: String!
): Document!

Parse the content of the given InputStream as an XML document and return a new DOM Document object. An IllegalArgumentException is thrown if the InputStream is null.

Parameters
is InputStream!: InputStream containing the content to be parsed.
systemId String!: Provide a base for resolving relative URIs.
Return
Document! A new DOM Document object.
Exceptions
java.io.IOException If any IO errors occur.
org.xml.sax.SAXException If any parse errors occur.

parse

Added in API level 1
open fun parse(uri: String!): Document!

Parse the content of the given URI as an XML document and return a new DOM Document object. An IllegalArgumentException is thrown if the URI is null null.

Parameters
uri String!: The location of the content to be parsed.
Return
Document! A new DOM Document object.
Exceptions
java.io.IOException If any IO errors occur.
org.xml.sax.SAXException If any parse errors occur.

parse

Added in API level 1
abstract fun parse(is: InputSource!): Document!

Parse the content of the given input source as an XML document and return a new DOM Document object. An IllegalArgumentException is thrown if the InputSource is null null.

Parameters
is InputSource!: InputSource containing the content to be parsed.
Return
Document! A new DOM Document object.
Exceptions
java.io.IOException If any IO errors occur.
org.xml.sax.SAXException If any parse errors occur.

reset

Added in API level 1
open fun reset(): Unit

Reset this DocumentBuilder.

This method removes both the EntityResolver and ErrorHandler instances associated with this DocumentBuilder and sets all internal properties to false including those set by the DocumentBuilderFactory when this DocumentBuilder was created.

setEntityResolver

Added in API level 1
abstract fun setEntityResolver(er: EntityResolver!): Unit

Specify the EntityResolver 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 EntityResolver!: The EntityResolver to be used to resolve entities present in the XML document to be parsed.

setErrorHandler

Added in API level 1
abstract fun setErrorHandler(eh: ErrorHandler!): Unit

Specify the ErrorHandler 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 ErrorHandler!: The ErrorHandler to be used by the parser.