Hello, I was wondering what method would you use to do the following:

I have a string that contains html nested tags, then I need to get the index in which a html tag starts and where it ends.

Code:
<html>
 <div>
  <p>
   asdsad
  </p>
 </div>
</html>
I'm currently looping through all the characters from the string detecting < and > characters to find where the tag ends and where it starts but it seems it's not working.

How would you do it ? regex ? use a html parser ?

Cheers.