Habin Habin - 1 year ago 101
Java Question

Namespace issue in xpath using XMLUnit 1.6

I'm using XMLUnit 1.6 for testing my xsl trasfromations.Mentioned below are two sample tests.
In test1(), xml is NOT having namespace. test1 is getting passed which is expected.
In test2(), xml is having namespace and test is getting failed.I'm not able to give the correct xpath that is expected in the second
argument of


public void test1() throws Exception {

String resultXML = "<MyXML><Value>3</Value></MyXML>";

public void test2() throws Exception {

String resultXML = "<tns:MyXML xmlns:tns=\"testns\"><tns:Value>3</tns:Value></tns:MyXML>";


Could anybody please help with the correct value for xpath . Thanks in advance.

Answer Source

You could use the xpath : //*[local-name()='Value']/text()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download