<div><span></div>to convert to
<div></div>and I would want
<div></span></div>to also convert to
I've found a way to do this using the following code:
Code: Select all
$domDoc = new DOMDocument();
$htmlCodeString = $domDoc = $domDoc->saveHTML();
There are several reasons that I do not want to do this. They are:
1.) This method is capable of catching when a tag is not properly closed, but it throws the falling warning.
DOMDocument::loadHTML(): Unexpected end tag
2.) The HTML it generates is intended to be on a separate page. It decks the variable out with the
<html></html>tags, and throws
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">in for good measure.
How can I do what I want without doing something I don't want at the same time? I suppose I could always just use the string length function to hack my way around this, but I would like to avoid doing so if possible.