File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XPathAPI and namespaces

 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a problem with XPATH and namespaces.
Could anyone please help ?

I'm using apache XPathAPI, with java 1.4.
It works fine as long as there are no namespaces.
Unfortunately, when adding namespaces to the xml, XPathAPI fails to find the desired element (returning null).



What am i doing wrong ? Do you know of a better way to do it ?
Thanks.
 
Jesus Angeles
Ranch Hand
Posts: 2068
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sol Mam-Orn:


Thanks.


If you do like this, does it work?

Node subNode = XPathAPI.selectSingleNode(root, "tempuri:body/tempuri:status", nsResolverNode);
 
Sol Mayer-Orn
Ranch Hand
Posts: 311
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jesus Angeles:
If you do like this, does it work?

Node subNode = XPathAPI.selectSingleNode(root, "tempuri:body/tempuri:status", nsResolverNode);


Thanks for replying... unfortunately this suggestion doesn't work
(it gives a runtime error message, which actually makes sense here: "prefix must resolve to a namespace: tempuri" ).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic