Java JDom空指针异常

Java JDom空指针异常,java,xml,Java,Xml,我试图通读XML 我的XML文件是 <datasource caption='Benfords' inline='true' name='oracle.41859.392947812499' version='8.2'> <connection authentication='RDBMS' class='oracle' port='1531' **server**='honeyWillServer' service ="de06" username='IIUSE

我试图通读XML

我的XML文件是

 <datasource caption='Benfords' inline='true' name='oracle.41859.392947812499' version='8.2'>
      <connection authentication='RDBMS' class='oracle' port='1531' **server**='honeyWillServer'  service ="de06" username='IIUSER'>
        <relation name='TableauSQL' type='text'>
</Connection>
</datasource>    
任务很简单,我想钻取xml并使用setValue将服务器(在连接节点中)替换为所需的值。
我得到一个java.lang.NullPointerException。

首先

您的XML格式不正确:

<connection> </Connection> --? capital 'C' in end tag
而不是:

Element staff1 = rootNode.getChild("connection");

你能发布完整的堆栈跟踪吗?不能是同一元素的子元素,对吗?
Element staff1 = staff.getChild("connection"); // Connection is the child of datasource.
Element staff1 = rootNode.getChild("connection");