Solved

XPATH with Namespace using Dom4j

Posted on 2008-06-11
5
1,422 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

738 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