Forum Moderators: open
I'm trying to upgrade my pages to XHTML but simply cannot get them to display.
I've got this code as a test file:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>simple document</title>
</head>
<body>
<p>a simple paragraph</p>
</body>
</html>
I'm on IE6 and when I run it I get an error page in Japanese (I'm in Korea). What is possibl;y wrong with this page?
Also I was told that XHTML pages need to be named mypage.xhtm or .xhtml, but I see sites like macromedia.com have index.html pages with the XML declaration <?xml version="1.0" encoding="utf-8"?> as the first line of code.
If I make an .htm/.html page with this xml declaration I just get a parsing error and the page doesn't display.
How can I get these correctly coded xhtml pages to work, and what extension should I be using?
Many thanks,
Jeremy
<Sorry, no personal URLs. See TOS [webmasterworld.com]>
[edited by: tedster at 5:29 am (utc) on July 3, 2004]
To use XHTML Transitional 4.01 (which seems to be what you're going for, use the following doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Then alter your html tag to fit this:
<html xmlns="http://www.w3.org/1999/xhtml">
Finally, in your meta tag, make sure you use the content="application/xhtml+xml; charset=iso-8859-1" attribute (with the relevant charset).
Now your page should display as XHTML.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta content="application/xhtml+xml; charset=iso-8859-1" />
<head>
<title>simple document</title>
</head>
<body>
<p>a simple paragraph</p>
</body>
</html>
Take away the <?xml version="1.0" encoding="utf-8"?> it works, put it in, it doesn't. I'm not using any PHP or serverside scripting in this page. This declaration is ruining everything :)
Thanks,
Jeremy
[edited by: jeremymgp at 3:21 am (utc) on July 3, 2004]
What you can do is replace it with this:
<?php print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";?>
Notice the way PHP opens with "<?". That's what throws it for a loop. Also, the added slashes are used to escape the quote marks, or else you'd get more errors ;)
Birdman
Added: Or, you can edit your .htaccess file to remove the command that forces the server to parse all pages as PHP. If you DON'T use PHP at all, then it's just slowing the system down anyway.
That's what I wanted to hear, I thought it was something to do with PHP and my server setup, but I wasn't actually using PHP on my page so I coudn't figure it.
I implemented your fix <?php print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";?> and it works like a charm, the code displays as <?xml version=\"1.0\" encoding=\"utf-8\"?> and it works fine. Shame I have to use a workaround though, so I'll try and get my server reconfigured. Thanks man,
Best Regards,
Jeremy
One thing though. The backslashes should not be displayed in the HTML code. If they are there, then there is still a problem.
You could also do it like this:
<?php print "<?xml version='1.0' encoding='utf-8'?>";?>
Basically, changing the double quotes to singles so they don't need to be escaped.
Or:
<?php print '<?xml version="1.0" encoding="utf-8"?>';?>
Should work as well.