Nageswar, Jaya wrote:
Whenever I have a default namespace in my xml file, xpath expression is not returning any nodeset.

..


I am trying to use xpath expression as “//message”. My code is as follows. I am using xerces as well as xalan in my application.

..
Since I have default namespace xmlns=http://schemas.xmlsoap.org/wsdl/ in my input xml file I’m getting length as zero.

If I remove the default namespace them I am getting length as 3 which is correct for my xpath expression.

Please help me how xpath expression needs to be modified whenever we have default namespace.

Any help regarding xpath expressions whenever there are namespaces in the xml file are appreciated.
You need to use a namespace prefix in your XPath expressions:

"//ns:message"

You'll also need to implement a PrefixResolver derivative and pass an instance of that into the XPathEvaluator, so the XPath implementation can map the namespace prefix to the proper namespace URI. You can look at the existing PrefixResolver instances to see what's involved.

Dave

Reply via email to