Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/javax/xml/xpath/XPathFactory#constants) \| [Protected Ctors](https://developer.android.com/reference/javax/xml/xpath/XPathFactory#proctors) \| [Methods](https://developer.android.com/reference/javax/xml/xpath/XPathFactory#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/javax/xml/xpath/XPathFactory#inhmethods)

# XPathFactory


`
public


abstract
class
XPathFactory
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.xml.xpath.XPathFactory |

<br />

*** ** * ** ***

<br />

An `XPathFactory` instance can be used to create
`https://developer.android.com/reference/javax/xml/xpath/XPath` objects.

See `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance(java.lang.String)` for lookup mechanism.

<br />

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#DEFAULT_OBJECT_MODEL_URI` <br /> Default Object Model URI. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#DEFAULT_PROPERTY_NAME` <br /> The default property name according to the JAXP spec. |

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#XPathFactory()() ` <br /> Protected constructor as `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance()`, `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance(java.lang.String)` or `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance(java.lang.String,%20java.lang.String,%20java.lang.ClassLoader)` should be used to create a new instance of an `XPathFactory`. |

| ### Public methods ||
|---|---|
| ` abstract boolean` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#getFeature(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` <br /> Get the state of the named feature. |
| ` abstract boolean` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#isObjectModelSupported(java.lang.String)(https://developer.android.com/reference/java/lang/String objectModel) ` <br /> Is specified object model supported by this `XPathFactory`? <br /> |
| ` static final https://developer.android.com/reference/javax/xml/xpath/XPathFactory` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance()() ` <br /> Get a new `XPathFactory` instance using the default object model, `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#DEFAULT_OBJECT_MODEL_URI`, the W3C DOM. |
| ` static https://developer.android.com/reference/javax/xml/xpath/XPathFactory` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance(java.lang.String,%20java.lang.String,%20java.lang.ClassLoader)(https://developer.android.com/reference/java/lang/String uri, https://developer.android.com/reference/java/lang/String factoryClassName, https://developer.android.com/reference/java/lang/ClassLoader classLoader) ` |
| ` static final https://developer.android.com/reference/javax/xml/xpath/XPathFactory` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance(java.lang.String)(https://developer.android.com/reference/java/lang/String uri) ` <br /> Get a new `XPathFactory` instance using the specified object model. |
| ` abstract https://developer.android.com/reference/javax/xml/xpath/XPath` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newXPath()() ` <br /> Return a new `XPath` using the underlying object model determined when the `XPathFactory` was instantiated. |
| ` abstract void` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#setFeature(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String name, boolean value) ` <br /> Set a feature for this `XPathFactory` and `XPath`s created by this factory. |
| ` abstract void` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#setXPathFunctionResolver(javax.xml.xpath.XPathFunctionResolver)(https://developer.android.com/reference/javax/xml/xpath/XPathFunctionResolver resolver) ` <br /> Establish a default function resolver. |
| ` abstract void` | ` https://developer.android.com/reference/javax/xml/xpath/XPathFactory#setXPathVariableResolver(javax.xml.xpath.XPathVariableResolver)(https://developer.android.com/reference/javax/xml/xpath/XPathVariableResolver resolver) ` <br /> Establish a default variable resolver. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### DEFAULT_OBJECT_MODEL_URI

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String DEFAULT_OBJECT_MODEL_URI
```

<br />

Default Object Model URI.

<br />

<br />

Constant Value:

"http://java.sun.com/jaxp/xpath/dom"


### DEFAULT_PROPERTY_NAME

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String DEFAULT_PROPERTY_NAME
```

<br />

The default property name according to the JAXP spec.

<br />

<br />

Constant Value:

"javax.xml.xpath.XPathFactory"


## Protected constructors

### XPathFactory

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected XPathFactory ()
```

<br />

Protected constructor as `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance()`, `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance(java.lang.String)`
or `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#newInstance(java.lang.String,%20java.lang.String,%20java.lang.ClassLoader)`
should be used to create a new instance of an `XPathFactory`.

<br />

<br />

## Public methods

### getFeature

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean getFeature (String name)
```

<br />

Get the state of the named feature.


Feature names are fully qualified `https://developer.android.com/reference/java/net/URI`s.
Implementations may define their own features.
An `https://developer.android.com/reference/javax/xml/xpath/XPathFactoryConfigurationException` is thrown if this `XPathFactory` or the `XPath`s
it creates cannot support the feature.
It is possible for an `XPathFactory` to expose a feature value but be unable to change its state.

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: Feature name. <br /> |

| Returns ||
|---|---|
| `boolean` | State of the named feature. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `name` is `null`. |
| `https://developer.android.com/reference/javax/xml/xpath/XPathFactoryConfigurationException` | if this `XPathFactory` or the `XPath`s it creates cannot support this feature. |

### isObjectModelSupported

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean isObjectModelSupported (String objectModel)
```

<br />

Is specified object model supported by this `XPathFactory`?

<br />

<br />

| Parameters ||
|---|---|
| `objectModel` | `String`: Specifies the object model which the returned `XPathFactory` will understand. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if `XPathFactory` supports `objectModel`, else `false`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `objectModel.length() == 0`. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `objectModel` is `null`. |

### newInstance

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final XPathFactory newInstance ()
```

<br />

Get a new `XPathFactory` instance using the default object model,
`https://developer.android.com/reference/javax/xml/xpath/XPathFactory#DEFAULT_OBJECT_MODEL_URI`,
the W3C DOM.

This method is functionally equivalent to:

```
  newInstance(DEFAULT_OBJECT_MODEL_URI)
```

Since the implementation for the W3C DOM is always available, this method will never fail.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/xpath/XPathFactory` | Instance of an `XPathFactory`. <br /> |

### newInstance

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static XPathFactory newInstance (String uri, 
                String factoryClassName, 
                ClassLoader classLoader)
```

<br />

<br />

| Parameters ||
|---|---|
| `uri` | `String` <br /> |
| `factoryClassName` | `String` <br /> |
| `classLoader` | `ClassLoader` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/xpath/XPathFactory` | Instance of an `XPathFactory`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `uri.length() == 0`. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `uri` is `null`. |
| `https://developer.android.com/reference/javax/xml/xpath/XPathFactoryConfigurationException` | If the specified object model is unavailable. |

### newInstance

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final XPathFactory newInstance (String uri)
```

<br />

Get a new `XPathFactory` instance using the specified object model.

To find a `XPathFactory` object,
this method looks the following places in the following order where "the class loader" refers to the context class loader:

1. If the system property `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#DEFAULT_PROPERTY_NAME` + ":uri" is present, where uri is the parameter to this method, then its value is read as a class name. The method will try to create a new instance of this class by using the class loader, and returns it if it is successfully created.
2. ${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for. If present, the value is processed just like above.
3. The class loader is asked for service provider provider-configuration files matching `javax.xml.xpath.XPathFactory` in the resource directory META-INF/services. See the JAR File Specification for file format and parsing rules. Each potential service provider is required to implement the method:

             https://developer.android.com/reference/javax/xml/xpath/XPathFactory#isObjectModelSupported(java.lang.String)
           
   The first service provider found in class loader order that supports the specified object model is returned.
4. Platform default `XPathFactory` is located in a platform specific way. There must be a platform default XPathFactory for the W3C DOM, i.e. `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#DEFAULT_OBJECT_MODEL_URI`.

If everything fails, an `XPathFactoryConfigurationException` will be thrown.

Tip for Trouble-shooting:

See `https://developer.android.com/reference/java/util/Properties#load(java.io.InputStream)` for exactly how a property file is parsed.
In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it.
For example:

```
  http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
```

<br />

<br />

| Parameters ||
|---|---|
| `uri` | `String`: Identifies the underlying object model. The specification only defines the URI `https://developer.android.com/reference/javax/xml/xpath/XPathFactory#DEFAULT_OBJECT_MODEL_URI`, `http://java.sun.com/jaxp/xpath/dom` for the W3C DOM, the org.w3c.dom package, and implementations are free to introduce other URIs for other object models. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/xpath/XPathFactory` | Instance of an `XPathFactory`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If `uri.length() == 0`. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `uri` is `null`. |
| `https://developer.android.com/reference/javax/xml/xpath/XPathFactoryConfigurationException` | If the specified object model is unavailable. |

### newXPath

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract XPath newXPath ()
```

<br />

Return a new `XPath` using the underlying object
model determined when the `XPathFactory` was instantiated.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/javax/xml/xpath/XPath` | New instance of an `XPath`. <br /> |

### setFeature

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setFeature (String name, 
                boolean value)
```

<br />

Set a feature for this `XPathFactory` and `XPath`s created by this factory.


Feature names are fully qualified `https://developer.android.com/reference/java/net/URI`s.
Implementations may define their own features.
An `https://developer.android.com/reference/javax/xml/xpath/XPathFactoryConfigurationException` is thrown if this `XPathFactory` or the `XPath`s
it creates cannot support the feature.
It is possible for an `XPathFactory` to expose a feature value but be unable to change its state.


All implementations are required to support the `https://developer.android.com/reference/javax/xml/XMLConstants#FEATURE_SECURE_PROCESSING` feature.
When the feature is `true`, any reference to an external function is an error.
Under these conditions, the implementation must not call the `https://developer.android.com/reference/javax/xml/xpath/XPathFunctionResolver`
and must throw an `https://developer.android.com/reference/javax/xml/xpath/XPathFunctionException`.

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String`: Feature name. <br /> |
| `value` | `boolean`: Is feature state `true` or `false`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `name` is `null`. |
| `https://developer.android.com/reference/javax/xml/xpath/XPathFactoryConfigurationException` | if this `XPathFactory` or the `XPath`s it creates cannot support this feature. |

### setXPathFunctionResolver

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setXPathFunctionResolver (XPathFunctionResolver resolver)
```

<br />

Establish a default function resolver.

Any `XPath` objects constructed from this factory will use
the specified resolver by default.

A `NullPointerException` is thrown if `resolver` is `null`.

<br />

<br />

| Parameters ||
|---|---|
| `resolver` | `XPathFunctionResolver`: XPath function resolver. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `resolver` is `null`. |

### setXPathVariableResolver

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void setXPathVariableResolver (XPathVariableResolver resolver)
```

<br />

Establish a default variable resolver.

Any `XPath` objects constructed from this factory will use
the specified resolver by default.

A `NullPointerException` is thrown if `resolver` is `null`.

<br />

<br />

| Parameters ||
|---|---|
| `resolver` | `XPathVariableResolver`: Variable resolver. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | If `resolver` is `null`. |