Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6747653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:28:10+00:00 2026-05-26T12:28:10+00:00

I parse all TD elements of a webpage. There is 1 TD element which

  • 0

I parse all TD elements of a webpage.
There is 1 TD element which seems to be empty.

EUR 1,00
EUR 2,00
empty  <--
EUR 3,00

How can i fix this and remove the empty item from arraylist (results)?

Thank you in advance.

My code:

 try {

          Document doc = Jsoup.parse(kpo);  
       // Get all td's 
          Elements waardes = doc.select("TBODY"); 
          Iterator<Element> postIt = waardes.select("td").iterator();
       // Iterator over those elements      
          //ListIterator<Element> postIt = waardes.listIterator(); 
          postIt.next();
          postIt.next();
          postIt.next();
          postIt.next();

          SearchResults sr1 = new SearchResults();
          //SearchResults sr2 = new SearchResults();

          while (postIt.hasNext()) { 

                sr1 = new SearchResults();
                // Add the game text to the ArrayList      
                sr1.setNaam(postIt.next().text()); 
                sr1.setWaarde(postIt.next().text());  
                results.add(sr1); 
          } 

          } catch (Exception e) { 
        // TODO Auto-generated catch block 
            e.printStackTrace(); 
          } 

          return results;

        } 

Edit:
I got it to work like:

while (postIt.hasNext()) {  

    String naam = postIt.next().text();
    String waarde = postIt.next().text();

    sr1 = new SearchResults();

    // Add the text to the ArrayList     
    if (!naam.trim().isEmpty() && !waarde.trim().isEmpty()) {
       sr1.setNaam(naam);
       sr1.setWaarde(waarde);
       results.add(sr1); 
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:28:10+00:00Added an answer on May 26, 2026 at 12:28 pm

    Just make sure that you already don’t add the SearchResults when the waarde is empty. This way you don’t need to fiddle afterwards with cleaning the one and other.

    So, replace

    sr1.setWaarde(postIt.next().text());  
    results.add(sr1); 
    

    by for example

    String waarde = postIt.next().text();
    
    if (!waarde.trim().isEmpty()) {
        sr1.setWaarde(waarde);  
        results.add(sr1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to select all elements that have a given style using
I am trying to parse through all elements in a single radio button (or
I am working to parse a form and obtain the values of all elements,
i'm using JSoup to parse a webpage like this , and make it into
I want to parse a web page in Groovy and extract all of the
I'm looking to parse some CXML in PHP...basically all I'm looking to get the
I want to parse the following XML document to resolve all entities in it:
I want to parse an html document after it has loaded and discover all
I need the Perl regex to parse plain text input and convert all links
I need to parse a bunch of incoming xml documents, they all have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.