Valid content-type for XML, HTML and XHTML documents

后端 未结 1 1188
难免孤独
难免孤独 2020-11-30 01:10

What are the correct content-types for XML, HTML and XHTML documents?

I need to write a simple crawler that only fetches these kinds of files.

Nowadays http:

相关标签:
1条回答
  • 2020-11-30 01:40

    HTML: text/html, full-stop.

    XHTML: application/xhtml+xml, or only if following HTML compatbility guidelines, text/html. See the W3 Media Types Note.

    XML: text/xml, application/xml (RFC 2376).

    There are also many other media types based around XML, for example application/rss+xml or image/svg+xml. It's a safe bet that any unrecognised but registered ending in +xml is XML-based. See the IANA list for registered media types ending in +xml.

    (For unregistered x- types, all bets are off, but you'd hope +xml would be respected.)

    0 讨论(0)
提交回复
热议问题