Hi Juergen 

I simply must add this to the FAQ, its one of those
questions that keeps coming up.

The answer is that you were on the right track with
the setNamespaceURIs. Though in XPath expressions you
must use a prefix. Note that the prefix is irrelevant
and syntax sugar - what matters is the local name of
the element and the namespace URI that its associated
with.

So using a prefix of whatever you like, say "foo"
would work, even if the source document was using no
prefix (or the default namespace as its often called).

The prefixes do not need to match, only the URIs.

James

FROM: Juergen FeyDATE: 01/17/2002 02:45:55SUBJECT: 
[dom4j-dev] Problem with default namespace (no prefix)
and XPATH Hi,

I am running into this big problem with the default
namespace we`re
using here. All documents are defined as:

<Article xmlns="http://....."; ..>

so, there is no prefix, which is legal since all
elements without a prefix
will be using this default namespace.

But ..

    HashMap idg = new HashMap();

    idg.put ("", "http://...";);
    xpathSelector.setNamespaceURIs(idg);

does not work of cause.

If i strip the "xmlns:..."-String from the XML file
everything works, but
that is not really a workable option.

So my question is: How can i use the default namespace
with XPATH to
find the elements i am looking for?

Any help/hint greatly welcomed.



Juergen Fey


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to