Solved

XPATH with Namespace using Dom4j

Posted on 2008-06-11
5
1,414 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet filter example 37 72
printf performancy 11 73
java imports not found 4 30
collection output issue 9 39
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

820 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