You can, but it gets rather ugly:

doc.selectSingleNode("//*[namespace-uri()='NAMESPACE' and
local-name()='what']"
        + "/*[namespace-uri()='NAMESPACE' and local-name()='ever']");

Most likely you'll be able to omit the test for namespace-uri and just
test on the local name, but it still won't win any beauty contests.

-- Steen

> -----Original Message-----
> From: Tom Oehser [mailto:tom@;toms.net] 
> Sent: 31. oktober 2002 17:05
> To: [EMAIL PROTECTED]
> Subject: [dom4j-dev] selecting nodes when URI is known but 
> prefix is not
> 
> 
> 
> Hi,
> 
> I find myself doing things like:
> 
>       private Map uris = new HashMap();
>       uris.put("m",NAMESPACE);
>       org.dom4j.XPath xpath = doc.createXPath("//m:what/m:ever");
>       xpath.setNamespaceURIs(uris);
>       org.dom4j.Node node = xpathSel.selectSingleNode(doc);
> 
> Instead of
> 
>       doc.selectSingleNode("//?:what/?:ever");
> 
> Because I know the namespace URI but not the prefix (which 
> could be the default prefix).
> 
> Is there an easier way to select a node using an xpath when I 
> don't know the prefix?
> 
> -Tom
> 
> 
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future 
> of Java(TM) technology. Join the Java Community 
> Process(SM) (JCP(SM)) program now. 
> http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
> _______________________________________________
> dom4j-dev mailing list
> [EMAIL PROTECTED] 
> https://lists.sourceforge.net/lists/listinfo/dom4j-dev
> 



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to