is there a way to validate that inside html tags there is an ul with several li objects (I am using groovy). I need that in order to check that the html generated its valid in an unit test.
I would like to :
- Extract the number of li elements with its data
- Validate that the is inside an specified with an specified class, inside that div could be different html tags but i don´t care about them
<div class="example">...<ul><li>Element1</li><li>Element2</li><ul>...</div>
I have tried the most simplest way: <li>.+?</li>
, with this I am able to extract the li elements, but I need to check the valid ul div structure.
why this is not working ? <div class='example'>.+?<ul>(<li>.+?</li>)*<ul>.+?</div>
How should it be ?
Any tips?
Thanks a lot