Serving Out XML Files from an HTTP Server

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XSLT Developer's Guide

Serving Out XML Files from an HTTP Server

XML documents can be delivered through a standard HTTP server by registering the "text/xml" Multipurpose Internet Mail Extension (MIME) type on the server. Installing Microsoft® Internet Explorer 5.0 on the server registers the XML MIME type and associates it with the .xml and .xsl file extensions. This association is used by Microsoft Internet Information Services (IIS) and the Microsoft Personal Web Server (PWS) to determine the MIME type.

When using either of these servers on systems that do not have Internet Explorer 5.0 installed, the XML MIME type can be registered by running the register-xml.regregister-xml.reg file. This file inserts the appropriate keys into the registry. The changes will not take effect until the computer has been restarted.

Alternatively, for IIS on systems that do not have Internet Explorer 5.0 installed, the XML MIME type can be registered using the Internet Service Manager console.

  1. Select Default Web Site and open the Properties dialog box.
  2. Select the HTTP Headers tab, click the File Types button, and select New Type.
  3. Type .xml in the Associated extension box, and text/xml in the Content type (MIME) box. Click OK.

The .xsl extension can be registered in a similar fashion.

The .xml and .xsl extensions can also be registered to the XML MIME type manually from the File Types dialog box under Folder Options. Extensions indicating other types of XML files for purposes of browsing must be manually registered as MIME type "text/xml".

Declaring the XML MIME Type in an Active Server Page

When generating XML dynamically using Active Server Pages (ASP), the content type must be declared in the .ASP file itself. The ContentType property of the Response object indicates that the result is XML. Include the following line in Active Server Pages that are delivering XML.

<% Response.ContentType = "text/xml" %>
Important   If the XML MIME type is not registered on the server, the MIME type sent to Internet Explorer in the HTTP header will be incorrect — often "text/plain". Although Internet Explorer 5.0 often can detect and process these documents, conflicts can arise between the various detection algorithms. For example, part of Channel Definition Format (CDF) file detection involves looking for <CHANNEL> tags — an XML document delivered with an incorrect MIME type and that uses elements named <CHANNEL> could mistakenly be handed off to the CDF processor instead of displayed as an XML document. Avoid these tricky and hard-to-debug problems by making sure your server correctly sends the XML MIME type.

Internet Explorer 5.0 also recognizes documents of MIME type "application/xml" as XML. For more information, see Internet Engineering Task Force Request for Comments 2376, XML Media Types Other Resources.

See Also

Deploying XSLT Solutions