Menu

Scanner All Word in HTML File

Help
2005-11-29
2013-04-27
  • Sauro Salotti

    Sauro Salotti - 2005-11-29

    Hello I'm an Italian Student,I'm newbie for java programming.
    I use Html parser for scanning all word of html parsing,but i can't scanning all line of html because it too long.
    For example my code is :

    public static void CreaNode(String url) throws ParserException{
    Parser parser = new Parser(url);
    Node Nodes [] = parser.extractAllNodesThatAre(Tag.class);
    String [] listatag =new String [Nodes.length];
    for (int i=0;i<Nodes.length;i++){
    Node tag1= Nodes[i];
    String tag ="";
    tag = tag1.toString();
    listatag[i] = tag;
    //System.out.println(listatag[i]);
    }
    ControlTag("alt",listatag);
    }
    private static String CleanString(String controllo) {
    //int index =controllo.indexOf(":");
    //String pippo = controllo.substring(index+1,controllo.length());
    String pippo = controllo;
    return pippo;
    }
    private static void ControlTag(String searchtag, String[] listatag) {
    int count = 0;
    for (int i=0;i<listatag.length;i++){
    count =count+1;
    String controllo = listatag[i];
    boolean b = controllo.matches("(?i).*"+searchtag+".*");
    if (b==true) {
    String pippo= CleanString(controllo);
                         System.out.println("Linea--> "+i+" "+pippo);

    I want found all "alt" occurrences in html
    but if It stay at the end of a line i don't find it because the end of the line is replaced by "..."

    Can I scanning all length line?

    Sorry for my English ...

     
    • Derrick Oswald

      Derrick Oswald - 2005-11-29

      Don't use toString() to get the string from the nodes, use toHtml() or toPlainTextString() instead.

      toString() is just a programmers aid, and doesn't report the complete contents.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.