Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between serving a page as text/xml and application/xhtml+xml?

What is the difference between serving a page as text/xml and application/xhtml+xml ?

like image 434
Pacerier Avatar asked Oct 24 '25 05:10

Pacerier


1 Answers

Quote from the specification:

The 'application/xhtml+xml' media type [RFC3236] is the primary media type for XHTML Family documents. 'application/xhtml+xml' should be used for serving XHTML documents to XHTML user agents (agents that explicitly indicate they support this media type). This media type must be used when writing documents using XHTML Family document types that add elements and attributes from foreign namespaces, such as XHTML+MathML [XHTML+MathML].

So use application/xhtml+xml to serve your XHTML pages if the client supports it, otherwise you could use text/html.

Another quote from the specification:

  1. If the Accept header explicitly contains application/xhtml+xml (with either no "q" parameter or a positive "q" value) deliver the document using that media type.

  2. If the Accept header explicitly contains text/html (with either no "q" parameter or a positive "q" value) deliver the document using that media type.

  3. If the accept header contains "* /*" (a convention some user agents use to indicate that they will accept anything), deliver the document using text/html.

In other words, requestors that advertise they support XHTML family documents will receive the document in the XHTML media type, and all other requestors that (at least claim to) support HTML or "everything" will receive the document using the HTML media type. Dealing with user agents that satisfy none of these criteria is outside the scope of this document.

When an XHTML document does NOT adhere to the guidelines, it should only be delivered as media type application/xhtml+xml.

text/xml should not be used for serving XHTML web pages. You could use it to serve other XML documents that do not represent XHTML.

like image 131
Darin Dimitrov Avatar answered Oct 26 '25 18:10

Darin Dimitrov