title: How to get all the elements from the HTML document using Jsoup Library?
body: <p>I'm trying to parse the HTML tag using <code>Jsoup library</code>. I want to iterate over through all the elements. and replace <code>"\br"</code> with a <code>""</code>. I using the below method:</p>
  
  <pre><code> private void parseHtmlDoc(Document doc){
          StringBuilder builder;
          List&lt;String&gt; descriptionList=new ArrayList&lt;String&gt;();
           builder=new StringBuilder();
          Elements elementList=doc.getAllElements();
          for(Element element:elementList){
              if(element.equals(doc.select("\r\n"))){
                  builder.append(element.text());
                  builder.append("\n");
                  Log.d("HTML",builder.toString());
              }
  
              else if(element.equals(doc.select("&lt;img&gt;"))){
                  if(builder.length()!=0) {
                      String text = builder.toString();
                      descriptionList.add(text);
                      Log.d("HTML", text);
                  }
  
                   builder=new StringBuilder();
  
              }
  
          }
  </code></pre>
  
  <p>But my app is crashing at this line:</p>
  
  <pre><code>   for(Element element:elementList)
  </code></pre>
  
  <p>I'm I doing anything wrong here...Please help me to fix this problem.</p>
  
  <p>Updated Code:</p>
  
  <p>I changed the implementation to the below code:</p>
  
  <pre><code> Elements elements=doc.getElementsByTag("html");
          for(Element element:elements){
              Log.d("HTML",element.text());
          }
  </code></pre>
  
  <p>Now, I'm getting all the tags inside the element. This element has internal tags like, <p>, <br> &lt;\n> . I want to iterate through each tag and replace them. I'm stuck at this point. I don't know how to get the child elements from the Html tag.</p>