DOM saveHTML() not outputting XHTML Strict
| From: | Chris | Date: | Mon, 23 Jan 2006 18:35:13 +0000 |
| Subject: | DOM saveHTML() not outputting XHTML Strict | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-229114@lists.php.net to get a copy of this message | ||
Hi,
I have a class which will build, and output, an HTML table. To create the internal elements more simply I'm using a DOMDocument, with a root element of 'table' then outputting with the ->saveHTML() method.
This has worked fine during development, but I've run into a problem. In this table I have a drop-down list (<select> with <options>). If I want to set an option to selected I do this:
$oOption->setAttribute('selected','selected');
Which, unfortunately, outputs as
<option selected> instead of <option selected="selected">
I need my output HTML to conform to XHTML strict.
Is there any way I can force it to output XHTML Strict compliant tags? I guess the theoretically ideal solution would be to have a complete XHTML Strict DOMDocument, with my table in the body, then just outputting the table portion. I haven't found a way to do that without some nasty substr()'s and whatnot.
Is there anyway to specify that a DOMDocument is really a portion of an XHTML Strict page, and output that accordingly?
Just for clarity's sake, outputting ->saveXML() isn't a real attrictive solution because it *always* puts the <?xml ?> tag at the front, which I definitely do not want.
Thanks,
Chris