Im importing an XML feed as content onto my page with PHP. If the content has a spare open or closed div then it messes up my page:
<div>
<div>Stuff</div>
<div>Stuff</div>
<div>Stuff</div>
Or
<div>Stuff</div>
<div>Stuff</div>
<div>Stuff</div>
</div>
I cant remove all divs as they are needed for the layout of the content. With php can I remove any divs that either open but dont close, or close but dont open? Thanks
The most effective solution would probably be the use of the Tidy extension. It has several methods which will allow you to clean and repair markup.
In particular, you would want to look at tidy::cleanRepair, which should remove any broken tags, and produce “clean” output.