[jdom-interest] Problem with getText() / jdom b9 rc2

Bradley S. Huffman hip at a.cs.okstate.edu
Fri Apr 25 10:11:30 PDT 2003


Simon McLeish writes:

> // Load the hostname, port and handlers
> Element portElt = root.getChild("port");

Big dummy me for not seeing this the first time, getChild("port") returns
the first child in no namespace (Namespace.NO_NAMESPACE), the "port" element
is in the default namespace which is "http://www.angel.ac.uk/rm_config".
Use the full version of getChild

    Namespace rm_config_ns = Namespace.getNamespace(
                               "http://www.angel.ac.uk/rm_config");
    Element portElt = root.getChild("port", rm_config_ns);
   
Brad

> The document looks like:
> 
> <?xml version="1.0"?>
> <rm_config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xmlns="http://www.angel.ac.uk/rm_config"
> 	xsi:schemaLocation="http://www.angel.ac.uk/rm_config 
> http://www.angel.ac.uk/schemas/rm_config.xsd"
> 	name="Angel">
> (irrelevant content)
> <host>bungo.lse.ac.uk</host>
> <port type="unprotected">5557</port>
> (more irrelevant content)
> </rm_config>



More information about the jdom-interest mailing list