Hello, I'm trying to write a HTML parser that will find links then store them. However when given a simple input page example it only runs and finds the first link, then quits. I assume its a simple looping issue I'm having. Any help is appreciated, Thanks.
The Input:
Code where I'm trying to grab them from a string that HTML is saved to.Code:<HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY><a href="index.html">Hello World.</a><a href="secondURL.html">Another Link</a><a href="yetanotherone2.html">Last One</a></BODY></HTML>
Code:for(index1=0;index1<savedLines.length();) { index1=savedLines.indexOf("href",index1); System.out.println("First href" + index1); index1=savedLines.indexOf("\"", index1); System.out.println("First Quote: " + index1); index2=savedLines.indexOf("\"", (index1+1)); System.out.println("Second Quote: " + index2); String NewSTR=savedLines.substring((index1+1),index2); System.out.println("New String: "+ NewSTR); if(index1==index2); { dispose(); System.exit(0); } index1=index2; }




Reply With Quote