[jdom-interest] Null Pointer Exception from getTextTrim() method

Victor Toni victor.toni at ebuconnect.de
Thu Jun 23 03:50:39 PDT 2005


I wonder if the NPE is really thrown from the method (which I don't 
believe).
If you realize that the NPE exception was actually thrown because you 
tried to call a method of a "null" object you should again look at your 
code, at the JDOM javadocs etc.

Anand, Rajesh wrote:

>     Sorry, that was a typo...
>  
>     it should be...
>  
> *    Line1 - Element childelem1 = element.getChild("ClosingPrice", 
> element.getNamespace());*
> *                        *
> *        Line 2 -String date[x] =  childelem1.getTextTrim();*
> ** 
>     *regards,*
>  
>  
>
> */Rajesh Anand/*
> *Tel: + (44) (0) 207 996 1152*
> *Mob: + (44) (0) 7947273151*
> *Email:Rajesh_anand at ml.com*
>
>     -----Original Message-----
>     *From:* Victor Toni [mailto:victor.toni at ebuconnect.de]
>     *Sent:* 23 June 2005 11:33
>     *To:* Anand, Rajesh
>     *Subject:* Re: [jdom-interest] Null Pointer Exception from
>     getTextTrim() method
>
>     Maybe you should take a closer look at the names of your variables.
>     Usually one would use some breakpoints, logging messages, etc.
>     before saying something like:
>
>     My loop doesn't work with JDOM.
>     Here is my code snippet:
>
>     while(false) {
>         // some JDOM stuff
>     }
>
>
>     Anand, Rajesh wrote:
>
>>             Folks,
>>
>>             here is my code snippet....
>>
>>            * Line1 - Element childelem2 =
>>     element.getChild("ClosingPrice", element.getNamespace());*
>>     *                        *
>>     *        Line 2 -String date[x] =  childelem1.getTextTrim();*
>>
>>             and here is the part of XML I'm trying to read...
>>
>>            * <getIndex:Price> *
>>     *       
>>     <getIndex:PriceEffectiveDate>2005-05-10</getIndex:PriceEffectiveDate>
>>     *
>>     *        <getIndex:ClosingPrice>2.99</getIndex:ClosingPrice> *
>>     *        </getIndex:Price>*
>>
>>             So, why is the 2nd line giving me Null Pointer error
>>     instead of returning a value of "2.99"??
>>
>>             Any helps will be greatly appreciated.
>>
>>     */Rajesh Anand/*
>>     *Email:Rajesh_anand at ml.com*
>>
>>     ------------------------------------------------------------------------
>>     If you are not an intended recipient of this e-mail, please
>>     notify the sender, delete it and do not read, act upon, print,
>>     disclose, copy, retain or redistribute it. Click here
>>     <http://www.ml.com/email_terms/>for important additional terms
>>     relating to this e-mail.     http://www.ml.com/email_terms/
>>     ------------------------------------------------------------------------
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>To control your jdom-interest membership:
>>http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20050623/4f9e869e/attachment.htm


More information about the jdom-interest mailing list