Re: [Htmlparser-user] NullPointer Exception: NodeList.add method, htmlparser 1_5
Brought to you by:
derrickoswald
From: Riaz u. <ru...@ya...> - 2006-03-16 13:18:00
|
The error is occuring at this statement: nodelistOfLinks.add(listOfSpanTags.elementAt(i).getParent()); Ian Macfarlane <ian...@gm...> wrote: 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 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 when > 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 what I > can do? > > public static NodeList extractLinkFromSpanTag(String url) throws > ParserException > { > int i =0; > > NodeList nodelistOfLinks = null; > Parser parser = new Parser(url); > // Step 2. Collecting Tags in a list. > NodeList list = 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 = list.extractAllNodesThatMatch(new > TagNameFilter ("SPAN"),true); > > while(i < listOfSpanTags.size()) > { // Beginning While loop to extract links > Span spanTag = > (Span)listOfSpanTags.elementAt(i); > // System.out.println(listOfSpanTags.size()); > // We only need SPAN tags with attribute "class = > 'recenttimedate'" > // Move to the link in the span tag > if(spanTag.getText().equals("span class=recenttimedate")) > > 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. > > > ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642 _______________________________________________ Htmlparser-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlparser-user --------------------------------- Relax. Yahoo! Mail virus scanning helps detect nasty viruses! |