text/xml
API Design

Meaning

text/xml is the MIME media type that identifies a payload as XML-formatted text, enabling parsers, browsers, and APIs to correctly interpret the body of a message. It solves the ambiguity of how to deserialize incoming data when multiple formats are possible. It is triggered whenever an HTTP request or response carries XML data and the sender needs to declare the encoding.

Primary Function

Content type identification

Communicative Purpose

Declares that a message body is XML text so receivers can select the correct parser and processing pipeline.

Pattern

Content-Type: text/xml; charset=utf-8

Função primária

Content type identification

Propósito comunicativo

Declares that a message body is XML text so receivers can select the correct parser and processing pipeline.

Situações de gatilho

Web APIs: setting Content-Type on XML request or response bodies

Contextos

HTTP, REST APIs, SOAP, RSS and Atom feeds, email MIME, web servers, API gateways

Padrão

Content-Type: text/xml; charset=utf-8

Colocados típicos

  • Content-Type header
  • Accept header
  • charset parameter
  • XML parser
  • SOAP envelope
  • RSS feed

Substituições comuns

  • application/xml: stricter RFC 7303 variant preferred for new APIs

Erros comuns

Using text/xml without charset: omitting the encoding parameter → receivers may guess wrong encoding and corrupt non-ASCII characters

Similar / contraste

application/xml: same payload, stricter RFC type, preferred for machine-to-machine

Interferências

Coming from JSON-heavy APIs: may default to application/json and overlook text/xml → check the API contract; XML services still require text/xml or application/xml

Família do chunk

  • MIME types
  • Content-Type header
  • application/xml
  • application/json

Nuance

When NOT to use: avoid text/xml for new machine-to-machine APIs where application/xml is preferred per RFC 7303. Performance: no measurable runtime cost beyond header parsing. Boundary condition: text/xml historically had weaker rules around charset and processing instructions than application/xml, which is why the latter is recommended for new systems.

Efeito pragmático

Ensures correct content negotiation between client and server, preventing XML payloads from being misrouted to JSON or HTML parsers and avoiding silent data corruption.

Dica de memória

text/xml is the name tag you pin to an XML envelope so the mailroom knows to send it to the XML sorter, not the JSON one.

Upgrade path

application/xml (RFC 7303) for stricter, modern XML APIs

Frequência: HighFormulaicidade: Fully fixedPrioridade de aquisição: Recognition firstPrioridade de output: BothTag de espaçamento: Long-term

Log in to save chunks.