JavaCake
JavaCake

Reputation: 4115

XML shows up as plain text

I retrieve XML from a external provider, and for debugging i usually view it from the browser. Unfortunately the case is that only Internet Explorer is able to render the data as XML. All other browser as Chrome, Safari, Firefox all render it as plain text for some reason.

Can anybody explain why this is the case?

Thanks.

Upvotes: 1

Views: 12964

Answers (1)

zambotn
zambotn

Reputation: 785

Try to(if you can):

  • force the mimetype of the returning page to text/xml
  • control the declaration of the xml to check if its correct
  • control the DOCTYPE declaration if is correct

You would paste here your code/the returned XML to show what is wrong!

ADDED LATER

Infact if the XML is not well formacted (ex: theres not a good escape of the attribute's value on some elements) The browser show all as plain text. Try to validate the text using the W3C XML Validator

Then as i said, in the very first point, the returning mimetype in the request can be wrong: i have an example of you could find in the header sometimes(wrong example):

 POST /path/to/the/service/ HTTP/1.1
 Host: www.example.com
 Content-Type: text/plain; charset=utf-8
 Content-Length: length

 <?xml version="1.0" encoding="utf-8"?>
 ....

If you look at the Content-Type you will see Content-Type: text/plain; charset=utf-8 that would be Content-Type: text/xml; charset=utf-8 but the only way to fix that is modify the source code of the webservice that response with xml file. To verify that you can, for example using Chrome press <F12>, choose Network and reload the page(pointing to the resource that you want to look at) and take a look to the Type's column.

Upvotes: 2

Related Questions