1. Home
  2. Computing & Technology
  3. Web Design / HTML

Why do browsers display code when viewing XML?

By Jennifer Kyrnin, About.com

Question: Why do browsers display code when viewing XML?

Answer:

Web browsers only know how to display one type of XML: XHTML. All other XML that is opened in a Web browser will display as plain markup code unless you tell the browser how to display that markup. In other words, you could markup a complete XML document and never tell it how to display in a browser or in a printout. In fact, most XML has no styles attached to it, because they aren't meant to be viewed in Web browsers. Instead they are used as data sources for Web applications like with Ajax.

The simplest way to display XML in a nice fashion is to include SHTML tags in the markup. This tells Web browsers how to display the content. You can also use CSS style sheets to style XML and have it display in browsers that way.

More Web Design / HTML Q&A

Explore Web Design / HTML

More from About.com

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. XML
  5. Beginning XML
  6. FAQ: Do browsers know how to display XML automatically? Why do browsers display code when viewing XML?

©2008 About.com, a part of The New York Times Company.

All rights reserved.