Parsing the html through Jsoup

Tuesday, July 8, 2014

I have a Html text like below Ex: Format One : Ordered list



String htmlText = "<ol> <li>Text1</li>
<li>Text2</li>
<li>Text3</li>
<li>Text4</li>
</ol>";


Format Two : Unordered List



String htmlText = "<ul> <li>TextA</li>
<li>TextB</li>
<li>TextC</li>
<li>TextD</li>
</ul>";


Format three : both ordered and unordered list



String htmlString = "<ol>
<li>Text 1</li>
<li>Text 2</li>
</ol>

<ul>
<li>Text a</li>
<li>Text b</li>
<li>Text c</li>
</ul>

<ol>
<li>Text 1</li>
<li>Text 2</li>
</ol>";


Now i have to iterate the html string coming from backend and if the html text contains an Ordered list i have to append numbers to the ordered text If the html text contains an unordered i have to append my dot to the unordered text. If the html string contains both ordered and unordered items then i have to append number to ordered and dot to unordered text.


How can parse that html string and append according to the specific element?







http://ift.tt/VDdC6n