XHTML
application/xhtml+xml
Magic Bytes
Offset: 0
3C 68 74 6D 6C 20 78 6D 6C 6E 73 3D
Extensible HyperText Markup Language (XHTML) is a family of XML markup languages that mirror or extend versions of HTML, developed and maintained by the World Wide Web Consortium. It is primarily used to provide strict XML conformance for web content, facilitating integration with automated data-processing tools and structured document workflows. While largely replaced by HTML5, it remains a legacy standard utilized in digital publishing and software environments requiring strict syntax validation.
Validation Code
How to validate .xhtml files in Python
Python
def is_xhtml(file_path: str) -> bool:
"""Check if file is a valid XHTML by magic bytes."""
signature = bytes([0x3C, 0x68, 0x74, 0x6D, 0x6C, 0x20, 0x78, 0x6D, 0x6C, 0x6E, 0x73, 0x3D])
with open(file_path, "rb") as f:
return f.read(12) == signature
How to validate .xhtml files in Node.js
Node.js
function isXHTML(buffer: Buffer): boolean {
const signature = Buffer.from([0x3C, 0x68, 0x74, 0x6D, 0x6C, 0x20, 0x78, 0x6D, 0x6C, 0x6E, 0x73, 0x3D]);
return buffer.subarray(0, 12).equals(signature);
}
Go
func IsXHTML(data []byte) bool {
signature := []byte{0x3C, 0x68, 0x74, 0x6D, 0x6C, 0x20, 0x78, 0x6D, 0x6C, 0x6E, 0x73, 0x3D}
if len(data) < 12 {
return false
}
return bytes.Equal(data[:12], signature)
}
API Endpoint
GET
/api/v1/xhtml
curl https://filesignature.org/api/v1/xhtml