<html>
<blockquote type=cite class=cite cite><br>
Jon Sharp wrote:<br>
<blockquote type=cite class=cite cite>I tried XPath.addNamespace() but
without any joy, eg following retuns 0 items in List:<br>
Namespace
ns=Namespace.getNamespace("<a href="http://www.xxxx.com/envelope" eudora="autourl">http://www.xxxx.com/envelope</a>");<br>
XPath xp = XPath.newInstance("/TopLevElement");<br>
xp.addNamespace(ns);<br>
List xlist = xp.selectNodes(tdoc);</blockquote><br>
The key point to remember is that there is no default namespace in XPath.
That is, whether your document uses namespace prefixes or not, you have
to use prefixes when referencing namespaces in XPath expressions. These
prefixes do not have to match the ones used in the document if you
declare the namespace using XPath.addNamespace().<br><br>
For example:<br>
Namespace ns=Namespace.getNamespace("foo",
"<a href="http://www.xxxx.com/envelope" eudora="autourl">http://www.xxxx.com/envelope</a>");<br>
XPath xp =
XPath.newInstance("/foo:TopLevElement");<br>
xp.addNamespace(ns);<br>
List xlist = xp.selectNodes(tdoc);<br><br>
Laurent</blockquote><br><br>
Many thanks, this sorted it out!<br><br>
Jon<br><br>
<x-sigsep><p></x-sigsep>
<hr>
<i>Jon Sharp tel: +44 1273 504004
mobile: +44 7739 430793 <br>
</i></html>