title: JSOUP find all images in HTML file with ALT attribute?
body: <p>Hi I am relatively new to Java but I am hoping to write a class that will find all the ALT (image) attributes in a HTML file using JSOUP. I am hoping to get an error message printed if there is no alt text on an image and if there is to remind users to check it.</p>
  
  <pre><code>import java.io.File;
  import org.jsoup.Jsoup;
  import org.jsoup.parser.Parser;
  import org.jsoup.nodes.Element;
  import org.jsoup.nodes.Node;
  import org.jsoup.nodes.Document;
  import org.jsoup.nodes.TextNode;
  import org.jsoup.select.Elements;
  
  
  public class grabImages {
                  File input = new File("...HTML");
                  Document doc = Jsoup.parse(input, "UTF-8", "file:///C:...HTML");
  
                  Elements img = doc.getElementsByTag("img"); 
                  Elements alttext = doc.getElementsByAttribute("alt");
  
                   for (Element el : img){
                       if(el.attr("img").contains("alt")){
                           System.out.println("is the alt text relevant to the image? ");
                           }
  
                           else { System.out.println("no alt text found on image");
                           }
                      }
  
  }       
  </code></pre>