XML

application/xml

Safe

Magic Bytes

Offset: 0
3C 3F 78 6D 6C

Extensible Markup Language (XML) is a text-based data format defined by the World Wide Web Consortium (W3C) to ensure human-readable and machine-readable documentation. It serves as a standard for web services, configuration files, and cross-platform data exchange between disparate software systems. Although generally safe, XML parsers may be vulnerable to external entity injection (XXE) attacks, which can lead to unauthorized data access or denial-of-service conditions if input is not properly sanitized.

Extension

.xml

MIME Type

application/xml

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .xml files in Python

Python
def is_xml(file_path: str) -> bool:
    """Check if file is a valid XML by magic bytes."""
    signature = bytes([0x3C, 0x3F, 0x78, 0x6D, 0x6C])
    with open(file_path, "rb") as f:
        return f.read(5) == signature

How to validate .xml files in Node.js

Node.js
function isXML(buffer: Buffer): boolean {
  const signature = Buffer.from([0x3C, 0x3F, 0x78, 0x6D, 0x6C]);
  return buffer.subarray(0, 5).equals(signature);
}
Go
func IsXML(data []byte) bool {
    signature := []byte{0x3C, 0x3F, 0x78, 0x6D, 0x6C}
    if len(data) < 5 {
        return false
    }
    return bytes.Equal(data[:5], signature)
}

API Endpoint

GET /api/v1/xml
curl https://filesignature.org/api/v1/xml

Related Formats