What is MIME type "application/gml+xml"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

application/gml+xml is the MIME type for Geography Markup Language files. It tells software that the file content is XML-based text used to describe geographic data.

These files carry spatial details such as coordinates, shapes, and feature properties. They work in mapping applications and geographic information systems (GIS).

Files using this MIME type use the GML extension. This ensures the correct handling and processing of geographic information by software.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: application/gml+xml    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="application/gml+xml">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'application/gml+xml');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

What software can open files served as application/gml+xml?

Because application/gml+xml indicates an XML-based format, you can open these files in any text editor like Notepad++ or VS Code to view the raw code. To visualize the geographic data as a map, you need specialized GIS software such as QGIS, ArcGIS, or FME. You can learn more about the specific extension at file-extension/gml.

How do I configure Apache to serve GML files correctly?

To ensure your Apache server sends the correct MIME type, add the following line to your .htaccess file or main configuration: AddType application/gml+xml .gml. This prevents browsers from misinterpreting the file as generic text or XML.

Will web browsers render application/gml+xml as a map automatically?

No, most modern browsers will display the raw XML tree structure or prompt you to download the file. To display the content as a map in a browser, you must use a JavaScript library like OpenLayers or Leaflet to parse the GML data and render it on a canvas.

What is the correct Nginx configuration for GML files?

For Nginx, you should update your mime.types file or add a types block within your server configuration. Use the directive: application/gml+xml gml;. After saving the changes, reload Nginx to apply the new content type.

Can I use text/xml instead of application/gml+xml?

While text/xml or application/xml will technically allow the file to transfer because GML is based on XML, it is considered bad practice. Using the specific application/gml+xml type ensures that client software knows specifically that the content conforms to the Open Geospatial Consortium (OGC) standards.

How does application/gml+xml differ from KML?

While both are XML-based, GML is designed for the transport and storage of complex geographic data, whereas KML (Keyhole Markup Language) is optimized for map visualization in tools like Google Earth. GML focuses on data integrity and exchange, while KML focuses on how the data looks.

Are there security risks associated with application/gml+xml?

Yes, because GML is an XML format, it is susceptible to XXE (XML External Entity) attacks if the parsing software is not configured to disable external entity resolution. Developers processing these files on a server should ensure their XML parsers are hardened against these injection vulnerabilities.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.