| Author |
XPath with namespace
|
Max Bogdanov
Greenhorn
Joined: Mar 12, 2011
Posts: 11
|
|
Hello!
I have no idea why this simple example does not work. Please give me same advice:
(if I remove namespace it works perfect)
Example output:
NamespaceContext implementation class:
Thanks, Max
|
OC-JA,OCP-JP,OCP-JWCD,OCE-EJBD,OCE-JPAD
|
 |
N Sahni
Ranch Hand
Joined: Jul 07, 2011
Posts: 55
|
|
Hi,
Everything looks good here except the namespace.
The namespace declared in xml is whereas namaspace set in namaspacecontext is Both does not match.
|
Thanks and Regards,
Nilesh Sahni | nsahni@infocepts.com | www.infocepts.com
|
 |
Max Bogdanov
Greenhorn
Joined: Mar 12, 2011
Posts: 11
|
|
N Sahni wrote:Hi,
Everything looks good here except the namespace.
The namespace declared in xml is whereas namaspace set in namaspacecontext is Both does not match.
It was my copy-paste mistake. I edited my post, the namespaces are same, I checked everything 1000 times))). Thanks.
|
 |
N Sahni
Ranch Hand
Joined: Jul 07, 2011
Posts: 55
|
|
Can you try modifying DocumentBuilderFactory instance like this:
I tried executing your code and replicating the issue. By setting builder.setNamespaceAware(true); it worked properly.
|
 |
Max Bogdanov
Greenhorn
Joined: Mar 12, 2011
Posts: 11
|
|
N Sahni wrote:Can you try modifying DocumentBuilderFactory instance like this:
I tried executing your code and replicating the issue. By setting builder.setNamespaceAware(true); it worked properly.
Thank you so much! Now it works. I didn't know that default value is false.
|
 |
 |
|
|
subject: XPath with namespace
|
|
|