<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(&quot;<a href="http://www.xxxx.com/envelope" eudora="autourl">http://www.xxxx.com/envelope</a>&quot;);<br>
XPath xp = XPath.newInstance(&quot;/TopLevElement&quot;);<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>
&nbsp;&nbsp; Namespace ns=Namespace.getNamespace(&quot;foo&quot;,
&quot;<a href="http://www.xxxx.com/envelope" eudora="autourl">http://www.xxxx.com/envelope</a>&quot;);<br>
&nbsp;&nbsp; XPath xp =
XPath.newInstance(&quot;/foo:TopLevElement&quot;);<br>
&nbsp;&nbsp; xp.addNamespace(ns);<br>
&nbsp;&nbsp; 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&nbsp;&nbsp;&nbsp; tel: +44 1273 504004&nbsp;&nbsp;&nbsp;
mobile: +44 7739 430793 <br>
</i></html>