<br><font size=2 face="sans-serif">With beta9 I'm trying to use XPath against a document with a default namespace such as:</font>
<br>
<br><font size=2 color=#008080 face="Courier New"><?</font><font size=2 color=#3f8080 face="Courier New">xml </font><font size=2 color=#800080 face="Courier New">version</font><font size=2 face="Courier New">=</font><font size=2 color=#4200ff face="Courier New">"1.0" </font><font size=2 color=#800080 face="Courier New">encoding</font><font size=2 face="Courier New">=</font><font size=2 color=#4200ff face="Courier New">"UTF-8"</font><font size=2 color=#008080 face="Courier New">?></font>
<br><font size=2 color=#008080 face="Courier New"><</font><font size=2 color=#3f8080 face="Courier New">definitions </font><font size=2 color=#800080 face="Courier New">name</font><font size=2 face="Courier New">=</font><font size=2 color=#4200ff face="Courier New">"name1" </font><font size=2 color=#800080 face="Courier New">xmlns</font><font size=2 face="Courier New">=</font><font size=2 color=#4200ff face="Courier New">"http://my/standard/"</font><font size=2 color=#008080 face="Courier New">></font>
<br><font size=2 face="Courier New"> </font><font size=2 color=#008080 face="Courier New"><</font><font size=2 color=#3f8080 face="Courier New">AAA</font><font size=2 color=#008080 face="Courier New">></font><font size=2 face="Courier New">aaa1</font><font size=2 color=#008080 face="Courier New"></</font><font size=2 color=#3f8080 face="Courier New">AAA</font><font size=2 color=#008080 face="Courier New">></font>
<br><font size=2 face="Courier New"> </font><font size=2 color=#008080 face="Courier New"><</font><font size=2 color=#3f8080 face="Courier New">AAA</font><font size=2 color=#008080 face="Courier New">></font><font size=2 face="Courier New">aaa2</font><font size=2 color=#008080 face="Courier New"></</font><font size=2 color=#3f8080 face="Courier New">AAA</font><font size=2 color=#008080 face="Courier New">></font>
<br><font size=2 color=#008080 face="Courier New"></</font><font size=2 color=#3f8080 face="Courier New">definitions</font><font size=2 color=#008080 face="Courier New">></font>
<br>
<br><font size=2 face="sans-serif">Without the default namespace in the document, this works fine:</font>
<br>
<br><font size=2 face="Courier New">XPath xpath = XPath.newInstance(</font><font size=2 color=#4200ff face="Courier New">"//AAA"</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">List results = xpath.selectNodes(myDocument);</font>
<br>
<br><font size=2 face="sans-serif">With the namespace in the document, the above code returns an empty list.</font>
<br>
<br><font size=2 face="sans-serif">If I try:</font>
<br>
<br><font size=2 face="Courier New">XPath xpath = XPath.newInstance(</font><font size=2 color=#4200ff face="Courier New">"//*"</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">List results = xpath.selectNodes(myDocument);</font>
<br>
<br><font size=2 face="sans-serif">... I get the three elements. AAA for instance is returned with namespace "</font><font size=2 color=blue face="Courier New">http://my/standard/</font><font size=2 face="sans-serif">" and qualified name AAA.</font>
<br>
<br>
<br><font size=2 face="sans-serif">I tried various ways of prefixing the element with the namespace without luck. I also tried:</font>
<br>
<br><font size=2 face="Courier New">XPath xpath = XPath.newInstance(</font><font size=2 color=#4200ff face="Courier New">"//AAA"</font><font size=2 face="Courier New">);</font>
<br><font size=2 face="Courier New">xpath.addNamespace(</font><font size=2 color=#820040 face="Courier New"><b>""</b></font><font size=2 face="Courier New">,</font><font size=2 color=#4200ff face="Courier New">"http://my/standard/"</font><font size=2 face="Courier New">);</font>
<br>
<br><font size=2 face="Courier New">and ...</font>
<br>
<br><font size=2 color=#3f8080 face="Courier New">XPath xpath = XPath.newInstance("//N:AAA N http://my/standard/");</font>
<br>
<br><font size=2 face="sans-serif">(The latter was based on an MSDN article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/html/xml05202002.asp).</font>
<br>
<br><font size=2 face="sans-serif">Both return an empty list. </font>
<br>
<br><font size=2 face="sans-serif">Can anyone point me in the right direction?</font>
<br>
<br><font size=2 face="sans-serif">Cheers<br>
Rob<br>
<br>
Rob Henley<br>
rhenley@uk.ibm.com</font>