Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

XPATH with Namespace using Dom4j

Posted on 2008-06-11
5
Medium Priority
?
1,450 Views
Last Modified: 2013-11-23
Hi,
I am using dom4j api and trying to evaluate an xpath. It is not working for me when the xml uses namespaces. Could you please let me know what changes should I make?
dom4j version: 1.6




ee-ques.txt
0
Comment
Question by:pattabi23in
  • 4
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 21764098
Your prefixes don't correspond to those defined in the document header - they must
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 21764154
e.g.

>> <m_SessionID>SESSION9</m_SessionID>

has no namespace set
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21764261
After fixing that your session id is returnable (my JDOM works) with the expression below:
 org.jdom.xpath.XPath xpath = org.jdom.xpath.XPath.newInstance("//soap:Header/snp:m_Header/snp:m_SessionID");

Open in new window

0
 

Author Closing Comment

by:pattabi23in
ID: 31466330
crazy thing that I did not notice the missing namespace. Thank you for spotting that. After the fix it worked.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21769336
:-)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question