Categories:
Author:
About It:
Get it:
Rate it:
Flag it:
Serve your site as application/xhtml+xml
If you want to serve your Textpattern site with the proper MIME type, you need to edit publish.php, found in the /textpattern/ directory. (written for 4.0.3)
- Backup and open /textpattern/publish.php in a text editor
- Search for “text/html” (lines 115 and 439)
- Replace
header("Content-type: text/html; charset=utf-8");with Mark Pilgrim’s code
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("content-type: application/xhtml+xml; charset=utf-8");
}
else {
header("content-type: text/html; charset=utf-8");
}
You can also download a new publish.php version too.
Posted here:
02 Jul 2006Article modified:
06 Nov 2006









Comments/questions? Leave a message in the form.
Commented (5)
They are some limitations when using this parser:
* If the XML of any page is not well-formed (for example a tag is not closed properly), the page will not display at all (a message describing the validation error will be displayed instead)
* The current XML parser of Mozilla browsers is unable to display the XHTML progressively while loading. The page will only display after it has been fully downloaded. The browsing experience may be affected by this behaviour.
Another limitation is that Javascript method document.write() , which is widely used, cannot be used when serving pages as XML. You need to use the DOM methods exclusively.
If we’re discussing mime type differences, we might as well add different CSS behavior, most notably the treatment of the body tag.
Also, Bobby van der Sluis has a solution for
document.writein real XHTML that might be of interest.Subscribe to this article's comments RSS feed. [ ? ] View Recent Comments across the site. Get a Gravatar.
Would you care to write a comment?