[jdom-interest] Problem with getChildText()

Tim Sawyer Tim.Sawyer at pancredit.com
Tue Jun 12 07:02:23 PDT 2001


I've just started using JDOM (beta 6) and it a huge improvement on the DOM
stuff I was trying to use before.  It's much more sensible now.  Well done
everyone. :-)

Anyway, on to my problem.  I have the following XML: 

<m:loginapplicationresponse xmlns:m="http://www.pancredit.com/methods"

It's the results of a login transaction, and I'm passing into my method the
Element that represents <loginapplicationresponse>.  This appears fine.  I
can then use getChildren(), iterate the list and print out the values.

However, if I try and use getChildText() to get the token and username text
from the message, it doesn't work.  Is there a known issue, or am I being
dense somewhere?

Here's the code:

        this.getLogger().logLineWithTime("Populate Login, element passed is
" + pMethod.toString());
        List lElements = pMethod.getChildren();
        ListIterator lElementsIterator = lElements.listIterator();
        while (lElementsIterator.hasNext())
          Element lElement = (Element)lElementsIterator.next();
        this.getLogger().logLineWithTime("Username is " +
        this.getLogger().logLineWithTime("Session token is " +

and here's the trace it produces:

12 June 2001 11:14:32 ->LoginSessionPanBean::populateLogin()
12 June 2001 11:14:32 Populate Login, element passed is [Element:
<m:loginapplicationresponse [Namespace: http://www.pancredit.com/methods]/>]
12 June 2001 11:14:32 [Element: <securitytoken [Namespace:
12 June 2001 11:14:32 securitytoken
12 June 2001 11:14:32 B58161BC80450563917176D737829A398ABA7004
12 June 2001 11:14:32 [Element: <username [Namespace:
12 June 2001 11:14:32 username
12 June 2001 11:14:32 tim
12 June 2001 11:14:32 username
12 June 2001 11:14:32 securitytoken
12 June 2001 11:14:32 Username is null
12 June 2001 11:14:32 Session token is null
12 June 2001 11:14:32 <-LoginSessionPanBean::populateLogin()

Is there a known bug with getChildText() ?  Am I missing something? I can
code around it, but it makes my code uglier.


Tim Sawyer
Development Consultant
Leeds, UK.

This e-mail and its attachments are for the use of the addressee only.
It may contain information that is legally privileged, confidential and 
exempt from  disclosure.  It is not a contract, and prices, data 
and other information are not warranted as to completeness or accuracy.  
Any comments or statements  made herein do not necessarily 
reflect those of PanCredit Systems Limited. If you are not the intended 
recipient you must not copy, distribute or disseminate this e-mail 
or attachments to anyone other than the addressee.  
If you receive this communication in error please advise us by telephone 
at once. 
PanCredit Systems Limited 
Tel:	+44 113 250 0260 
Fax:	+44 113 250 0621 

More information about the jdom-interest mailing list