Nageswar, Jaya wrote:
Hi Dave,

If I have namespace like xmlns:ns = "http://....."; in my xmal file
(sample.xml) then I can use the xpath expression as you suggested
("//ns:message").
Yes, because you are using the root element as the prefix resolver. Note this technique won't work if the namespace declaration doesn't occur on the root element. It also won't work if there is more than one mapping for the namespace declaration, but that's a different problem.


This xpath expression is able to retrieve desired results with the
following xpathevaluator with out using prefixresolver.

        evaluator.selectNodeList( nodelist,
                                                  dom_support,
                                       root_context_node,
                                                  expression.c_str(),
                                                  namespace_node);

But my question is how do we need to give xpath expression if we have
default namespace(xmlsns="http://....).
As I said, you have to map a prefix to the namespace and use that prefix in your XPath expressions. There is nothing magical about the default namespace, so you can map any prefix to the same namespace URI. Similarly, you can map two different prefixes to the same namespace URI and use either of them.

Dave

Reply via email to