title: Extract text from HTML tag one by one with Jsoup
body: <p>I am trying to extract text from a string of html tags with content.</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;CalaisSimpleOutputFormat&gt;
    &lt;Country count="13" relevance="0.771" normalized="China"&gt;China&lt;/Country&gt;
    &lt;Country count="4" relevance="0.598"&gt;Taiwan&lt;/Country&gt;
    &lt;City count="3" relevance="0.491" normalized="Beijing,China"&gt;Beijing&lt;/City&gt;
    &lt;NaturalFeature count="3" relevance="0.415"&gt;Yellow river&lt;/NaturalFeature&gt;
    &lt;Organization count="2" relevance="0.491"&gt;Communist Party&lt;/Organization&gt;
    &lt;Region count="2" relevance="0.258"&gt;Central Asia&lt;/Region&gt;
    &lt;Region count="2" relevance="0.315"&gt;East Asia&lt;/Region&gt;
    &lt;City count="1" relevance="0.304" normalized="Shanghai,China"&gt;Shanghai&lt;/City&gt;
    &lt;City count="1" relevance="0.304" normalized="Chongqing,China"&gt;Chongqing&lt;/City&gt;
    &lt;City count="1" relevance="0.101" normalized="Taipei,Taiwan"&gt;Taipei&lt;/City&gt;
    &lt;City count="1" relevance="0.304" normalized="Tianjin,China"&gt;Tianjin&lt;/City&gt;
    &lt;Continent count="1" relevance="0.053"&gt;Asia&lt;/Continent&gt;
    &lt;Country count="1" relevance="0.101" normalized="Japan"&gt;Japan&lt;/Country&gt;
    &lt;Country count="1" relevance="0.304" normalized="Macau"&gt;Macau&lt;/Country&gt;
    &lt;MedicalCondition count="1" relevance="0.160"&gt;hereditary monarchies&lt;/MedicalCondition&gt;
    &lt;NaturalFeature count="1" relevance="0.254"&gt;Himalaya&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.274"&gt;Gobi desert&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.208"&gt;Yellow sea&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.208"&gt;Pacific Ocean&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.291"&gt;Great Lakes&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.231"&gt;Yangtze river&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.274"&gt;Taklamakan desert&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.208"&gt;South China sea&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.231"&gt;Tibetan Plateau&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.208"&gt;Bohai sea&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.208"&gt;East sea&lt;/NaturalFeature&gt;
    &lt;NaturalFeature count="1" relevance="0.254"&gt;Tian Shan mountain ranges&lt;/NaturalFeature&gt;
    &lt;Organization count="1" relevance="0.062"&gt;G-20&lt;/Organization&gt;
    &lt;Organization count="1" relevance="0.073"&gt;U.N. Security Council&lt;/Organization&gt;
    &lt;Organization count="1" relevance="0.062"&gt;APEC&lt;/Organization&gt;
    &lt;Organization count="1" relevance="0.062"&gt;BRICS&lt;/Organization&gt;
    &lt;Organization count="1" relevance="0.062"&gt;BCIM&lt;/Organization&gt;
    &lt;Organization count="1" relevance="0.073"&gt;United Nations&lt;/Organization&gt;
    &lt;Organization count="1" relevance="0.062"&gt;Shanghai Cooperation Organisation&lt;/Organization&gt;
    &lt;Organization count="1" relevance="0.062"&gt;World Trade Organization&lt;/Organization&gt;
    &lt;Organization count="1" relevance="0.105"&gt;ROC government&lt;/Organization&gt;
    &lt;Position count="1" relevance="0.073"&gt;permanent member&lt;/Position&gt;
    &lt;Region count="1" relevance="0.208"&gt;East China&lt;/Region&gt;
    &lt;Region count="1" relevance="0.208"&gt;South China&lt;/Region&gt;
    &lt;Region count="1" relevance="0.254"&gt;South Asia&lt;/Region&gt;
    &lt;Region count="1" relevance="0.184"&gt;North China&lt;/Region&gt;
    &lt;Topics&gt;
       &lt;Topic Taxonomy="Calais" Score="0.558"&gt;Politics&lt;/Topic&gt;
       &lt;Topic Taxonomy="Calais" Score="0.534"&gt;War_Conflict&lt;/Topic&gt;
    &lt;/Topics&gt;
  &lt;/CalaisSimpleOutputFormat&gt;
  </code></pre>
  
  <p>The code has been extract the text successfully from thoes tags with the out put of:</p>
  
  <pre><code>ChinaChongqingShanghaiTaipeiTianjin................
  </code></pre>
  
  <p>I am wondering if there is a way to extract text one by one or split it with space, so that I can store that into a list. For example:</p>
  
  <pre><code>China
  Chongqing
  Shanghai
  Taipei
  ......
  </code></pre>
  
  <p>I have tried the codes like:</p>
  
  <pre><code>Document doc = Jsoup.parse(html);
  for (Element a : doc.select("CalaisSimpleOutputFormat")) {
      System.out.println(a.text());
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>for (Node child : XX.childNodes()) {
      if (child instanceof TextNode) {
          System.out.println(((TextNode) child).text());
      }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Document doc = Jsoup.parse(html);
  Element start = doc.select("CalaisSimpleOutputFormat").first();
  String text = start.text();
  </code></pre>
  
  <p>Both not working... Any suggestions?</p>