[jdom-interest] Problem with getChildText()

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


Hi,

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"
xmlns="http://www.pancredit.com/schemas">
<securitytoken>B58161BC80450563917176D737829A398ABA7004</securitytoken>
<username>tim</username>
</m:loginapplicationresponse>

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("->LoginSessionPanBean::populateLogin()");
        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(lElement.toString());
          this.getLogger().logLineWithTime(lElement.getName());
          this.getLogger().logLineWithTime(lElement.getText());
        }
        
        this.getLogger().logLineWithTime(PROP_USERNAME.toLowerCase());
        this.getLogger().logLineWithTime(PROP_TOKEN.toLowerCase());
        
        this.getLogger().logLineWithTime("Username is " +
pMethod.getChildText(PROP_USERNAME.toLowerCase()));
        this.setUserName(pMethod.getChildText(PROP_USERNAME.toLowerCase()));
 
this.setSecurityToken(pMethod.getChildText(PROP_TOKEN.toLowerCase()));
        this.getLogger().logLineWithTime("Session token is " +
pMethod.getChildText(PROP_TOKEN.toLowerCase()));
 
this.getLogger().logLineWithTime("<-LoginSessionPanBean::populateLogin()");

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:
http://www.pancredit.com/schemas]/>]
12 June 2001 11:14:32 securitytoken
12 June 2001 11:14:32 B58161BC80450563917176D737829A398ABA7004
12 June 2001 11:14:32 [Element: <username [Namespace:
http://www.pancredit.com/schemas]/>]
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.

Cheers,

Tim Sawyer
Development Consultant
PanCredit
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