This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
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 Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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: 2062
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