xml declaration and Apache

Problems with the Windows version of XAMPP, questions, comments, and anything related.

xml declaration and Apache

Postby ksassa » 07. October 2006 22:06

I have the following apples.html file placed in the htdocs folder of XAMPP:
Code: Select all
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- apples.html
     The contents of the apple frame (displayed in second frame of frames.html)
     of frames.html - a general description of fruit
     -->
<html xmlns = "http://www.w3.org/1999/xhtml">
  <head> <title> Apple Information </title>
  </head>
  <body>
    <p>
      Apple is the common name for any tree of the genus Malus, of
      the family Rosaceae. Apple trees grow in any of the temperate
      areas of the world. Some apple blossoms are white, but most
      have stripes or tints of rose. Some apple blossoms are bright
      red. Apples have a firm and fleshy structure that grows from
      the blossom. The colors of apples range from green to very
      dark red. The wood of apple trees is fine-grained and hard.
      It is, therefore, good for furniture construction. Apple trees
      have been grown for many centuries. They are propagated by
      grafting because they do not reproduce themselves.
    </p>
  </body>
</html>

When I open up IE and go to http://localhost/apples.html, I find that the html file is wrongly displayed. Instead of displaying the content of the <p> tag in the browser, it displays the file as an xml file with a listing of all the tags and their content with the xml declartion at the top. But if I take out the xml declaration or, alternatively, leave the xml declaration in and make the comment at the top to be very short (i.e. <!-- apples.html -->), then IE displays the html file properly and just shows the content of the <p> tag as expected. Also if I open up Windows Explorer and navigate to apples.html and double click on it, IE opens up and displays the html file properly. But yet I can open up http://localhost/apples.html in Firefox and it displays the html file properly even though IE won't. Is the xml declaration causing the html file to be displayed improperly in IE? And why does this problem only occur when I am trying to access it from Apache (i.e. in http://localhost/apples.html) and not from Windows Explorer? Is there a work around for this issue other than taking the xml declation out? Any insight that someone could give would be appreciated.

Thanks[/img]
ksassa
 
Posts: 3
Joined: 07. October 2006 21:55

Postby Izzy » 07. October 2006 23:59

Rename your file apples.xml and it will display correctly in all modern browsers including that Internet Explorer thing.

You have declared it as coded in xml so in the true sense it is not html code.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby ksassa » 08. October 2006 00:42

I renamed the file from apples.html to apples.xml and went to http://localhost/apples.xml through IE, but IE still displayed it in an xml format. I was trying to see if I could somehow get it to display in an html format. Again if I go to C:\Program Files\xampp\htdocs\apples.html and double click on the file, IE will display in an html format. But if I go to http://localhost/apples.html (or apples.xml), IE displays it in an xml format. But this only occurs for IE and not Firefox. And please forgive me for using that Internet Explorer thing.
ksassa
 
Posts: 3
Joined: 07. October 2006 21:55

Postby Izzy » 08. October 2006 00:56

It works for me in all browsers including IE if the file is named apples.xml and fails in IE if it is apples.html just like your IE test.

Try and clear your browser's cache and set it to load every visit to a page as the browser's cache is your worst enemy when testing at localhost level. Even after setting your cache thus, it is often wise to close then reopen your browser and try again.

For me now the apples.xml works fine in all browsers, the apples.html fails but only in IE using this url:
http://localhost/apples.html

Tested in
Opera 9.02
Opera 8.5
Internet Exploder 6.02 (thats as high a version as I will go ;) )
FireFox 1.507
SeaMonkey 1.05

Using XAMPP 1.5.4a out of the box.
Windows XP Pro

Thats all I can do for you.
Good luck!
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby Wiedmann » 08. October 2006 12:02

Code: Select all
<?xml version = "1.0" encoding = "utf-8"?>

When I open up IE and go to http://localhost/apples.html, I find that the html file is wrongly displayed.

Your problem is having a XML prolog in XHTML files you open in IE. In this case IE is using the quirk mode and not the standard compatible mode (and other odd behaviour).

You can just remove this line from your files and:
- add "AddCharset" (or AddDefaultCharset) for this file to your Apache config
- add a meta tag for content-type and charset to the head section of the file
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby ksassa » 09. October 2006 02:23

I discovered one workaround to the problem. If I take the comment above the html tag and move it to right below the html tag, I can place the apples.html file in the htdocs folder of xampp and go to http:''localhost/apples.html and the file displays properly in IE6 instead of displaying in xml format. I tested it with other files that had the problem and it worked for them. Not sure why it works ( :?: ), but it works ( :D ). Thanks for the help so far. If anyone has any more insight, I would be happy to hear from you.
ksassa
 
Posts: 3
Joined: 07. October 2006 21:55


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 70 guests