Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XPATH with Namespace using Dom4j

Posted on 2008-06-11
5
Medium Priority
?
1,436 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 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

722 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