wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes XPathAPI and namespaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XPathAPI and namespaces" Watch "XPathAPI and namespaces" New topic
Author

XPathAPI and namespaces

Sol Mayer-Orn
Ranch Hand

Joined: Nov 13, 2002
Posts: 311
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

Joined: Feb 26, 2005
Posts: 2057
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

Joined: Nov 13, 2002
Posts: 311

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
 
subject: XPathAPI and namespaces