Re: [Htmlparser-user] NullPointer Exception: NodeList.add method, htmlparser 1_5
Brought to you by:
derrickoswald
|
From: Ian M. <ian...@gm...> - 2006-03-15 21:07:29
|
The stack trace will tell you which line the NullPointerException was
thrown on. Why don't you tell us which line it's occuring on? That
will help pin it down.
Ian
On 3/15/06, Riaz uddin <ru...@ya...> wrote:
> Hi,
> I have attached the procedure below, now when I call this procedure it
> returns a null pointer excetion in the add method. It was working fine wh=
en
> I had it in the main function, but it does not run when I created this
> procedure, I think I need some java help on this, can someone suggest wha=
t I
> can do?
>
> public static NodeList extractLinkFromSpanTag(String url) throws
> ParserException
> {
> int i =3D0;
>
> NodeList nodelistOfLinks =3D null;
> Parser parser =3D new Parser(url);
> // Step 2. Collecting Tags in a list.
> NodeList list =3D parser.parse (null);
>
> //news links are at the span tag (time), spanList stores the
> span tags
> // Step 3. Keep only the SPAN tags in spanList.
> NodeList listOfSpanTags =3D list.extractAllNodesThatMatch(new
> TagNameFilter ("SPAN"),true);
>
> while(i < listOfSpanTags.size())
> { // Beginning While loop to extract links
> Span spanTag =3D
> (Span)listOfSpanTags.elementAt(i);
> // System.out.println(listOfSpanTags.size());
> // We only need SPAN tags with attribute "class =3D
> 'recenttimedate'"
> // Move to the link in the span tag
> if(spanTag.getText().equals("span class=3Drecenttimedate"=
))
>
> nodelistOfLinks.add(listOfSpanTags.elementAt(i).getParent());
> i++;
> }// End of while loop to extract links
> while(i < nodelistOfLinks.size())
> {
> System.out.println(nodelistOfLinks.elementAt(i));
> i++;
> }
>
> return nodelistOfLinks;
> }
>
> ________________________________
> Yahoo! Mail
> Bring photos to life! New PhotoMail makes sharing a breeze.
>
>
>
|