Skip to content

application/xml MIME Type — Meaning, Usage & Examples

application/xml
Extensions: .xml Class: application Spec: RFC 7303 (IANA registered)
View IANA registration ↗

application/xml means: application/xml is the registered media type for eXtensible Markup Language, a tree-structured format using custom tags, attributes and namespaces. It remains common in enterprise integration, SOAP services, document formats and feeds where schema validation and mixed content matter. Application media types carry structured or binary data that a program consumes rather than a human reading raw bytes. The subtype tells the receiver exactly which parser, decoder or handler to invoke, so sending the correct Content-Type is part of the API contract: a mismatch makes servers reject the body with 415 Unsupported Media Type or clients mis-parse the payload. You will encounter application/xml in contexts such as soap and legacy enterprise api envelopes; document and office formats built on xml (svg, xhtml, ooxml parts); rss/atom feeds and sitemap.xml files consumed by crawlers. It is commonly associated with the file extension(s) .xml. RFC 7303 recommends application/xml over the older text/xml for generic XML, because charset handling differs. Always declare the encoding in the XML prolog and keep it consistent with the Content-Type charset parameter.

Advertisement
Ad slot · ref-top

When you'll see application/xml

  • SOAP and legacy enterprise API envelopes
  • Document and office formats built on XML (SVG, XHTML, OOXML parts)
  • RSS/Atom feeds and sitemap.xml files consumed by crawlers

How to handle it

When handling an application type, set the Content-Type header explicitly on every request and response that carries a body, and advertise what you accept with the Accept header. Parse the payload with a library that matches the subtype rather than sniffing bytes, and validate the structure before trusting it. If a server returns 415, the declared type does not match what it expects — compare your header against the API documentation character for character, including parameters such as charset or boundary. As a final checklist for application types: register the exact subtype in your API documentation, validate incoming bodies against a schema before use, set X-Content-Type-Options: nosniff to stop MIME sniffing, and version your media types when the payload contract changes so old clients keep working.

Notes & gotchas

RFC 7303 recommends application/xml over the older text/xml for generic XML, because charset handling differs. Always declare the encoding in the XML prolog and keep it consistent with the Content-Type charset parameter.

Examples

HTTP
POST /v1/resource HTTP/1.1
Host: api.example.com
Content-Type: application/xml
Content-Length: 33

<root><item>example</item></root>
curl
curl -i -X POST -H "Content-Type: application/xml" --data-binary @payload https://api.example.com/v1/resource
JavaScript (fetch)
const res = await fetch("/v1/resource", { headers: { Accept: "application/xml" } });
// verify res.headers.get("Content-Type") starts with "application/xml"
const text = await res.text();   // handle according to the declared type
Python (requests)
import requests

with open("payload", "rb") as fh:
    res = requests.post("https://api.example.com/v1/resource", data=fh,
                        headers={"Content-Type": "application/xml"}, timeout=30)

Frequently asked questions

Should I use application/xml or text/xml?

Prefer application/xml for new work; text/xml is retained for compatibility. Both parse as XML, but application/xml has clearer default-encoding rules under RFC 7303.

What is application/soap+xml?

It is the dedicated media type for SOAP 1.2 messages, distinguishing them from generic XML so handlers can apply SOAP-specific processing.

What happens if I send the wrong application Content-Type?

Servers that validate media types answer 415 Unsupported Media Type, and clients may parse the body with the wrong decoder. Always set Content-Type to the registered type that matches your payload, and set Accept to the types you can handle.

Is application/octet-stream a safe default?

It means 'arbitrary binary bytes' and forces a download rather than inline handling. Use it only when the real type is unknown or you deliberately want a save-as dialog; otherwise declare the specific registered type.

How do I debug a 415 Unsupported Media Type response?

Compare the Content-Type you actually sent against what the endpoint documents, including parameters like charset and boundary. A 415 means the server refuses that media type; send the exact registered type it accepts and retry.

Advertisement
Ad slot · ref-in-article

Try the JSON Formatter

Beautify, validate and minify JSON with clear error messages.

Open tool →