XHT
application/xhtml+xml
Magic Bytes
Offset: 0
3C 68 74 6D 6C 20 78 6D 6C 6E 73 3D
XHT is a filename extension for Extensible HyperText Markup Language (XHTML) files, a reformulation of HTML as an XML application maintained by the World Wide Web Consortium. This format is utilized for web content and electronic publications requiring strict structural validation and compatibility with XML processing tools. Although modern development has shifted toward HTML5, XHTML remains a standard for EPUB ebooks and systems that prioritize rigid parsing over more flexible HTML syntax.
Validation Code
How to validate .xht files in Python
Python
def is_xht(file_path: str) -> bool:
"""Check if file is a valid XHT 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 .xht files in Node.js
Node.js
function isXHT(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 IsXHT(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/xht
curl https://filesignature.org/api/v1/xht