Class XpathResultMatchers
java.lang.Object
org.springframework.test.web.servlet.result.XpathResultMatchers
Factory for assertions on the response content using XPath expressions.
 
An instance of this class is typically accessed via
 MockMvcResultMatchers.xpath(java.lang.String, java.lang.Object...).
- Since:
- 3.2
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanValue(Boolean value) Evaluate the XPath and assert theBooleanvalue found.Evaluate the XPath and assert that content doesn't exist.exists()Evaluate the XPath and assert that content exists.nodeCount(int expectedCount) Evaluate the XPath and assert the number of nodes found.Evaluate the XPath and assert the number of nodes found with the given HamcrestMatcher.Evaluate the XPath and assert theDoublevalue found.Apply the XPath and assert theStringvalue found.
- 
Constructor Details- 
XpathResultMatchersprotected XpathResultMatchers(String expression, @Nullable Map<String, String> namespaces, Object... args) throws XPathExpressionExceptionProtected constructor, not for direct instantiation. UseMockMvcResultMatchers.xpath(String, Object...)orMockMvcResultMatchers.xpath(String, Map, Object...).- Parameters:
- expression- the XPath expression
- namespaces- the 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 Details- 
node
- 
nodeList- Since:
- 5.2.2
 
- 
existsEvaluate the XPath and assert that content exists.
- 
doesNotExistEvaluate the XPath and assert that content doesn't exist.
- 
nodeCountEvaluate the XPath and assert the number of nodes found with the given HamcrestMatcher.
- 
nodeCountEvaluate the XPath and assert the number of nodes found.
- 
string
- 
stringApply the XPath and assert theStringvalue found.
- 
number
- 
numberEvaluate the XPath and assert theDoublevalue found.
- 
booleanValueEvaluate the XPath and assert theBooleanvalue found.
 
-