I had an issue with with writing XPath using XMLUnit 2.0.0 and a default namespace. Here is my sample xml:
<a xmlns="uri:foo">
<b>value</b>
</a>
I couldn't access any elements with the following XMLUnit XPath code:
XPathEngine engine = new JAXPXPathEngine();
engine.setNamespaceContext(new HashMap<String, String>(1) {{
put(DEFAULT_NS_PREFIX, "uri:foo");
}});
assertEquals("value", engine.evaluate("/a/b",
Input.fromString("<a xmlns=\"uri:foo\"><b>value</b></a>").build()));
How do I access elements using XPathEngine/XPath using the default namespace?