• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XPath with namespace

 
Max Bogdanov
Greenhorn
Posts: 11
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
N Sahni
Ranch Hand
Posts: 55
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Everything looks good here except the namespace.
The namespace declared in xml is whereas namaspace set in namaspacecontext is Both does not match.
 
Max Bogdanov
Greenhorn
Posts: 11
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
C++ Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic