Поделиться через


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 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 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 installed, the XML MIME type can be registered using the Internet Service Manager console.

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 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 also recognizes documents of MIME type "application/xml" as XML.

See Also

Deploying XSLT Solutions