In a PHP function I am grabbing random chunks of HTML from my MySQL database that may or may not be well formed. An example is:
<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Heres something to display<br><br>Thanks,<br><br>
I am then returning this chunk of HTML from the PHP function and echoing what is returned onto the page into a <div> holder.
The problem I am having is that the above displays properly but because it doesn’t have closing tags it is playing havoc with the DOM when it is displayed. I can’t control how the HTML is formed because it comes from random email responses. My question is, is there anyway to encapsulate this chunk of HTML and cut it off from the rest of my page? Are there tags I can wrap this HTML in besides <div> that will ensure that regardless of how well formed it is, it will display but not interact with the rest of the page?
You can limit the damage caused by running it through a DOM parser. Example: