[jdom-interest] How do I use namespaces?
gmills at library.berkeley.edu
Wed Feb 4 15:49:44 PST 2004
I am using JDOM to parse documents that use attributes in a number
of different namespaces. The namespaces correspond to standards that are
being revised, so I can't be sure what their URI is (since each revision
is given a new URI).
The namespaces are declared in the root element, for example:
If, at some point in the document, I want to retrieve an attribute
that belongs to, say, the 'mods' namespace, can I just use the prefix?
Attribute x = myElement.getAttribute("x", "mods");
I don't think I can because getAttribute needs a Namespace and not
So do I have to do something more convoluted, such as retrieve the
namespaces defined on the element, search for the one with the name "mods"
and then include that one in the get Attribute call?
Or is there someway I can access the namespaces declared in the
In other words, what does it get me that namespaces are declared
in the root element?
Library Systems Office
More information about the jdom-interest