Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Every time I open an XML file, all I get is blank page instead of tag tree. The file itself is correct and loads okay, I can see it via View Source or in the Firebug. I've tried turning off all my addons and tried running Firefox in safe mode, but the problem was not solved.

I'm guessing that I've messed up my configuration somehow and Firefox now tries to render XML files as HTML ones. I've tried googling, but with no success. Help, please?

UPD: example file: http://lj.lain.ru/3/1273657698603.sample.xml Also I've noticed that somehow all of the browsers on the machine are now acting the same, so I'm changing the question accordingly

share|improve this question
    
Which version of Firefox do you use? The latest? –  SjoerdV May 12 '10 at 9:14
    
yes, of course. –  n1313 May 12 '10 at 9:36
    
Have you tried re-installing or is that not an option? It seems like some files are broken.. –  SjoerdV May 12 '10 at 9:36
    
This problem is here with me, like, for a year. I've upgraded Firefox several times. Does this count as reinstalling? –  n1313 May 12 '10 at 9:44
    
That probably counts. What operating system do you use and what browsers? For example, Internet Explorer, Firefox and Opera have a XML view, while Safari and Chrome display blank pages. –  SjoerdV May 12 '10 at 10:04

5 Answers 5

If the XML file is malformed, then the browser will not know what to do with it, and in my experience show nothing.

If the XML file is valid then most browsers (IE8, Chrome and Firefox) give a message like This XML file does not appear to have any style information associated with it. The document tree is shown below. and go into a special mode for showing XML files with features like being able to collapse code blocks.

Look here: XML Validator

share|improve this answer

I just got and solved a similar issue: from my ASP.NET MVC application I have a controller that returns raw XML which I want to see in the web browser as a DOM tree.

Chrome does it fine, but IE 11 simply shows a blank page.

The problem seems to be the "Content-Type" HTTP header: if it does not contain a charset value, IE simply shows a blank page (unless you have a Content-Disposition header, in which case IE offers you to save the XML).

So, the following HTTP response is OK for Chrome, but IE shows a blank page:

HTTP/1.1 200 OK
Cache-Control: private, s-maxage=0
Content-Type: application/xml
Server: Microsoft-IIS/8.0
Date: Fri, 25 Jul 2014 14:29:02 GMT
Content-Length: 693

<?xml version="1.0" encoding="utf-16"?><data>...</data>

Note: Make sure to provide the correct Content-Length, although I did not test what happens if the Content-Length header is missing or has a wrong value. Also, I removed the X- headers generated by IIS from this printout, but it is safe to leave them.


But the following does work under both IE and Chrome:

HTTP/1.1 200 OK
Cache-Control: private, s-maxage=0
Content-Type: application/xml; charset=utf-8
Server: Microsoft-IIS/8.0
Date: Fri, 25 Jul 2014 14:29:02 GMT
Content-Length: 693

<?xml version="1.0" encoding="utf-16"?><data>...</data>

The only difference it the addition of ; charset=utf-8 in the Content-Type header.

For ASP.NET MVC developers, this means that if you want to render raw XML and support IE, you cannot use:

string xmldata = ...
return this.File(Encoding.UTF8.GetBytes(xmldata), "application/xml");

Instead, the following works:

string xmldata = ...
Response.ContentType = "application/xml";
Response.ContentEncoding = Encoding.UTF8;
Response.AddHeader("Content-Length", Convert.ToString(xmldata.Length));
return this.Content(xmldata);

Kind regards.

share|improve this answer

This is specific to Firefox but I reckon is worth a shot:

Go to Help\Troubleshooting Information on the Firefox menu and click the button to open the containing folder of your profile.

Backup and then delete the mimeTypes.rdf file, close all instances of Firefox and open Firefox again.

This will force FF to re-generate the default actions for the mime types it knows about, this may fix the issue if it's caused by something weird FF is doing.

share|improve this answer

If you are loading the XML from a server, you need to set the header context type to text/xml.

For example, in PHP you need to put this ahead of your text output:

header("Content-type: text/xml");
share|improve this answer

Does the xml have a tag at the top similar to this?

<?xml version="1.0"?>

This will prepare the browser so it knows what to do.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.