public class XmlSearch extends Object
The purpose is to reduce the amount of duplicated code used in the test classes.
This class is not thread-safe. It not optimized-- it creates new factories and builders for every invocation. It is not suitable for use in production code.
This class does not catch errors. It passes errors up the call chain to provide developers with the most information possible when debugging test cases.
For XML related test assertions, use an org.custommonkey.xmlunit.XMLAssert methods like assertXpathEvaluatesTo().
For XML related test assertions in REST Assured responses, use the Hamcrest matcher method hasXpath().
Constructor and Description |
---|
XmlSearch() |
Modifier and Type | Method and Description |
---|---|
static XPathExpression |
compile(String xPathExpression) |
static String |
evaluate(String xPathExpression,
String xml) |
static String |
evaluate(String xPathExpression,
String xml,
boolean isNamespaceAware) |
protected static XPath |
getXPath() |
public static String evaluate(String xPathExpression, String xml) throws Exception
xPathExpression
- string representation of an XPath expressionxml
- string representation of an XML documentException
public static String evaluate(String xPathExpression, String xml, boolean isNamespaceAware) throws Exception
xPathExpression
- string representation of an XPath expressionxml
- string representation of an XML documentisNamespaceAware
- true if xpath expression uses namespaces, other wise pass false. For
example, if the XPath query "/csw:GetRecordsResponse", pass true. If the Xpath query is
"/GetRecordsResponse", pass false.Exception
public static XPathExpression compile(String xPathExpression) throws Exception
xPathExpression
- string representation of an xpath expressionException
protected static XPath getXPath()
This work is licensed under a Creative Commons Attribution 4.0 International License.