homepage Welcome to WebmasterWorld Guest from 54.204.64.152
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

    
XHTML Parsing help
pages end in .xhtm - code is fine - won't load Why?
jeremymgp




msg:701663
 2:32 am on Jul 3, 2004 (gmt 0)

Hi,

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]

 

jeremymgp




msg:701664
 2:35 am on Jul 3, 2004 (gmt 0)

I've tried replaceing the <html> tag with
<html xmlns="http://www.w3.org/1999/xhtml">

with this it just displays my page code actually in the browser. Gee, standards.

Jeremy

Numberman




msg:701665
 2:37 am on Jul 3, 2004 (gmt 0)

Name your pages .htm (or if you're using server-side scripting such as php then use the relevant extension).

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.

jeremymgp




msg:701666
 3:08 am on Jul 3, 2004 (gmt 0)

Thanks for your help, it works fine except for the same problem with the xml declaration, this is always the one that gets me. My code is:

<?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]

Birdman




msg:701667
 3:21 am on Jul 3, 2004 (gmt 0)

Sounds to me like your server is set up to parse all HTML extensions as PHP. The error comes from the opening tag (<?)
of the xml declaration.

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.

jeremymgp




msg:701668
 3:31 am on Jul 3, 2004 (gmt 0)

Hi Birdman,

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

Birdman




msg:701669
 3:01 pm on Jul 3, 2004 (gmt 0)

You're welcome!

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved