[jdom-interest] getText() question
Mike Engelhart
mengelha at denveronline.net
Thu Aug 17 07:28:43 PDT 2000
Hi,
My code below is returning 'null' when I run it and I can't figure out
what's going on.
try
{
SAXBuilder b = new SAXBuilder(true);
Document doc = b.build(new
java.io.File("configuration.xml"));
Element root = doc.getRootElement();
Element dbConfig =
doc.getRootElement().getChild("database");
Element userName = dbConfig.getChild("username");
// if I do this: System.out.println(userName); the
result is <username />
// so the next line is what is returning null
System.out.println(userName.getText());
}
catch(JDOMException e)
{
e.printStackTrace();
}
Here's the XML snippet that I'm reading in...
<database vendor="postgresql" version="7.0.2"
url="http://www.postgresql.org/">
<driver>org.postgresql.Driver</driver>
<host>some.host.com</host>
<port>5432</port>
<username>SomeUser</username>
<password>SomePassword</password>
<connections>
<initial>1</initial>
<maximum>50</maximum>
<timeout>30</timeout>
</connections>
</database>
Any ideas on what I'm doing wrong? I have a CVS from about 2 days ago.
Mike
More information about the jdom-interest
mailing list