I have a block of html in a string that is basically a list of divs... Each div has html inside that I want to parse seperately.
I am having trouble figuring out exactly how to loop over the initial divs.
Can anyone help?
An example of the html:
<div><!-- stuff in here --></div>
<div><!-- stuff in here --></div>
<div><!-- stuff in here --></div>
<div><!-- stuff in here --></div>
In this example I would expect the final code to loop round 4 times and provide me with the contents of each div
If it's XHTML, you can use SimpleXML:
This should work (if the HTML is in an external file):
And in case of a string containing the HTML, you could do:
which would produce: