XHTML2 (.xhtml2)
.xhtml2 file signature | application/xhtml+xml
Magic Bytes
Offset 0
3C 68 74 6D 6C 20 78 6D 6C 6E 73 3D
Sources: Apache Tika
Extension
.xhtml2
MIME Type
application/xhtml+xml
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .xhtml2 files in Python
def is_xhtml2(file_path: str) -> bool:
"""Check if file is a valid XHTML2 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 .xhtml2 files in Node.js
function isXHTML2(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);
}
How to validate .xhtml2 files in Go
func IsXHTML2(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
/api/v1/xhtml2
curl https://filesignature.org/api/v1/xhtml2
See the full API documentation for all endpoints and parameters.
Frequently Asked Questions
What is a .xhtml2 file?
A .xhtml2 file is a XHTML2 file.
What are the magic bytes for .xhtml2 files?
The magic bytes for XHTML2 files are 3C 68 74 6D 6C 20 78 6D 6C 6E 73 3D at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .xhtml2 file?
To validate a .xhtml2 file, read the first bytes of the file and compare them against the known magic bytes (3C 68 74 6D 6C 20 78 6D 6C 6E 73 3D) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .xhtml2 files?
The primary MIME type for .xhtml2 files is application/xhtml+xml.
Is it safe to open .xhtml2 files?
XHTML2 (.xhtml2) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.