XPATH with Namespace using Dom4j

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
pattabi23inAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CEHJConnect With a Mentor Commented:
e.g.

>> <m_SessionID>SESSION9</m_SessionID>

has no namespace set
0
 
CEHJCommented:
Your prefixes don't correspond to those defined in the document header - they must
0
 
CEHJCommented:
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
 
pattabi23inAuthor Commented:
crazy thing that I did not notice the missing namespace. Thank you for spotting that. After the fix it worked.
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.