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>

Format Two : Unordered List

String htmlText = "<ul> <li>TextA</li>

Format three : both ordered and unordered list

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

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

<li>Text 1</li>
<li>Text 2</li>

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?