$htmlString = "<ul> <li>Item 1</li> <li>Item 2</li> </ul> <ul> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> </ul>"
Note that this is just an example. Any request might have different number of lists, but it is always a series of unordered lists. I needed to get the text inside the
<li> tags and the following PHP code worked perfectly fine.
$DOM = new DOMDocument; $DOM->loadHTML($htmlString); $lis = $DOM->getElementsByTagName('li'); $items =; for ($i = 0; $i < $lis->length; $i++) $items = $lis[$i]->nodeValue;
And I get the array [Item 1,...,Item 5] inside
htmlString = "<ul> <li>Item 1</li> <li>Item 2</li> </ul> <ul> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> </ul>"