Xml – google chrome – opening an xml file via hyperlink show xml as regular text

browserfilegoogle-chromehyperlinkxml

i want to show an xml file inside an iframe.
it works fine in firefox and ie but in chrome show the xml as text.

so i wanted to check if this is a general problem.
for example:
if i use the View an XML food menu link that is located in http://www.w3schools.com/xml/xml_examples.asp then i get the xml shown as a text file.

if i right click the link and chose open in new tab it will show the xml as it should.
or if i open a new tab and put the url http://www.w3schools.com/xml/simple.xml it shows the file as an xml file.

if you press the right mouse button and select "open in a new tab" it will show the xml as it should.

i think that whatever causes this problem causes the problem i am facing.
so my questions are:

  1. what causes this ?
  2. is there a way around this problem ?
  3. is this a bug in chrome ?

thanks.

chrome version is 11.0.696.65

OS: windows xp,i have also checked this in windows 7

Best Solution

For me this is definitely Google Chrome bug. Try to use right-click on that link and select "Open link in new tab" or "Open link in new window" to see pretty printed XML.

enter image description here

There is target="_blank" attribute within anchor element, which causes that problem:

<a target="_blank" href="simple.xml">View an XML food menu</a>

Look at another site http://www.xmlfiles.com/examples/. There is no target="_blank" and links works well.

You can use Inspect Element → Edit as HTML option to remove that attribute target="_blank" and after that XML is printed well too.

enter image description here

Finally I found Chromium Issue 84128 (reported 26/5/2011, version 11.0.696.71) for that.

You don't need to add any explicite XSLT stylesheet. That's simply not the case here. If there is no stylesheet applied, then browser implicitly uses their built-in, default variant.

Edit:

I downloaded Google Chrome 12 beta (version 12.0.742.77 beta-m) beta-m and here this bug is solved.

Comment 93 by project member vse...@chromium.org, May 3, 2011 
The target="_blank" problem is already fixed in Chrome 12.

(from http://code.google.com/p/chromium/issues/detail?id=434)