org.springframework.test.web.servlet.result

## Class XpathResultMatchers

- java.lang.Object
- - org.springframework.test.web.servlet.result.XpathResultMatchers

    public class XpathResultMatchers
    extends Object

Factory for response content `ResultMatcher`'s using an XPath expression. An instance of this class is typically accessed via `MockMvcResultMatchers.xpath(java.lang.String, java.lang.Object...)`.

Since:
  3.2
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
`protected` `XpathResultMatchers(String expression, Map<String,String> namespaces, Object... args)` Protected constructor, not for direct instantiation.

### Method Summary

Methods
`ResultMatcher` `booleanValue(Boolean value)` Evaluate the XPath and assert the `Boolean` value found.
`ResultMatcher` `doesNotExist()` Evaluate the XPath and assert that content doesn't exist.
`ResultMatcher` `exists()` Evaluate the XPath and assert that content exists.
`ResultMatcher` `node(org.hamcrest.Matcher<? super Node> matcher)` Evaluate the XPath and assert the `Node` content found with the given Hamcrest `Matcher`.
`ResultMatcher` `nodeCount(int expectedCount)` Evaluate the XPath and assert the number of nodes found.
`ResultMatcher` `nodeCount(org.hamcrest.Matcher<Integer> matcher)` Evaluate the XPath and assert the number of nodes found with the given Hamcrest `Matcher`.
`ResultMatcher` `number(Double expectedValue)` Evaluate the XPath and assert the `Double` value found.
`ResultMatcher` `number(org.hamcrest.Matcher<? super Double> matcher)` Evaluate the XPath and assert the `Double` value found with the given Hamcrest `Matcher`.
`ResultMatcher` `string(org.hamcrest.Matcher<? super String> matcher)` Apply the XPath and assert the `String` value found with the given Hamcrest `Matcher`.
`ResultMatcher` `string(String expectedValue)` Apply the XPath and assert the `String` value found.

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

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

### Constructor Detail

#### XpathResultMatchers

    protected XpathResultMatchers(String expression,
                       Map<String,String> namespaces,
                       Object... args)
                           throws XPathExpressionException

Protected constructor, not for direct instantiation. Use `MockMvcResultMatchers.xpath(String, Object...)` or `MockMvcResultMatchers.xpath(String, Map, Object...)`.

Parameters:
  `expression` - the XPath expression
  `namespaces` - XML namespaces referenced in the XPath expression, or `null`
  `args` - arguments to parameterize the XPath expression with using the formatting specifiers defined in `String.format(String, Object...)`
Throws:
  `XPathExpressionException`

### Method Detail

#### node

    public ResultMatcher node(org.hamcrest.Matcher<? super Node> matcher)

Evaluate the XPath and assert the `Node` content found with the given Hamcrest `Matcher`.

#### exists

    public ResultMatcher exists()

Evaluate the XPath and assert that content exists.

#### doesNotExist

    public ResultMatcher doesNotExist()

Evaluate the XPath and assert that content doesn't exist.

#### nodeCount

    public ResultMatcher nodeCount(org.hamcrest.Matcher<Integer> matcher)

Evaluate the XPath and assert the number of nodes found with the given Hamcrest `Matcher`.

#### nodeCount

    public ResultMatcher nodeCount(int expectedCount)

Evaluate the XPath and assert the number of nodes found.

#### string

    public ResultMatcher string(org.hamcrest.Matcher<? super String> matcher)

Apply the XPath and assert the `String` value found with the given Hamcrest `Matcher`.

#### string

    public ResultMatcher string(String expectedValue)

Apply the XPath and assert the `String` value found.

#### number

    public ResultMatcher number(org.hamcrest.Matcher<? super Double> matcher)

Evaluate the XPath and assert the `Double` value found with the given Hamcrest `Matcher`.

#### number

    public ResultMatcher number(Double expectedValue)

Evaluate the XPath and assert the `Double` value found.

#### booleanValue

    public ResultMatcher booleanValue(Boolean value)

Evaluate the XPath and assert the `Boolean` value found.