file in abyss
フォーマット一覧へ戻る

Data

XML Extensible Markup Language

タグと属性で構造を表すテキスト形式。XML宣言またはルート要素から始まります。

Extensions .xml
MIME application/xml, text/xml

マジックナンバー

ファイルを解析
オフセット 0 XML declaration
3C 3F 78 6D 6C
<?xml
オフセット 0 XML element start
3C
<

構造

  1. Optional XML declaration
  2. Root element
  3. Elements
  4. Attributes
  5. Text nodes

注意点

  • HTMLやSVGも<から始まるため、ルート要素やMIMEの確認が必要です。

判定コード例

SIGNATURE = bytes.fromhex("3c3f786d6c")
OFFSET = 0

def is_xml(path: str) -> bool:
    with open(path, "rb") as f:
        f.seek(OFFSET)
        head = f.read(len(SIGNATURE))
    return head == SIGNATURE

実践的な使い方

ユースケース

Extensible Markup Language はデータ交換、インポート/エクスポート、パーサのテスト、検証ワークフローで使われます。エンコーディング・区切り文字・バージョン・コンテナ構造が実装の挙動を変えることがあります。

よくある判定ミス

  • .xml という拡張子だけではファイルの中身を保証できません。アップロードや変換の処理では、拡張子・MIMEタイプ・先頭バイト・形式固有の構造チェックを組み合わせるべきです。
  • Extensible Markup Language は 3C 3F 78 6D 6C または 3C のようなシグネチャで始まりますが、関連するコンテナや破損ファイルでは追加の検証が必要になる場合があります。

セキュリティ上の注意

形式が判定できたからといって、信頼できない入力が安全とは限りません。パーサ例外・巨大ファイル・想定外のエンコーディング・外部参照を考慮してください。

サンプルの活用

11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。

サンプルファイル

11 / 11 files
Sample Traits Size Source / license / SHA-256
Data

Small XML Feed

Small XML Feed is a Extensible Markup Language sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.

feed.xml
Type Sample
Small file
174 B
Generated CC0 1.0
SHA-256 d89cd1cd49f29370022d68796f91822e05ba7da6f064d73ddef2f27805d864ab
Download
Data

Blue Sky XML

Blue Sky XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.xml
Type Sample
Small file
282 B
SHA-256 bc5c4b587279c801b5ca1a82bf7a0b36af8920ef41262d3f059f1717b63bbe02
Download
Data

Flower Garden XML

Flower Garden XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.xml
Type Sample
Small file
353 B
SHA-256 bd78ce2cfb0e58645ffacbf1d524c83d63ca990fdb3822f97bacd3b510ecaf30
Download
Data

Navy Blue Sky XML

Navy Blue Sky XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.xml
Type Sample
Small file
386 B
SHA-256 3c6ccde88f123d6bcf4c02063c0da0c324632061ba674fdc387a0b5a5cc97184
Download
Data

Nature of the Sky XML

Nature of the Sky XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.xml
Type Sample
Small file
435 B
SHA-256 91b6cba624788fe4d84a48b09826b770f42ecd2d9127314853beb884bb5777b8
Download
Data

Sky Landscape XML

Sky Landscape XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.xml
Type Sample
Small file
477 B
SHA-256 cb040898b20920931b8b089ace0ce4fa01e1389e8777620ccddd56b431d3889c
Download
Data

Starry Sky XML

Starry Sky XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

06-starry-sky.xml
Type Sample
Small file
483 B
SHA-256 a4fe70ed3ad95894b2f66924883195c4e0b8b0d0571618d5cbedcb656e1c2dcc
Download
Data

Blue Night Sky XML

Blue Night Sky XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

07-blue-night-sky.xml
Type Sample
Small file
543 B
SHA-256 47bd294b1478afbdb31ba970ab3939a6ed074ad71160fc27133c52297be8dacd
Download
Data

Hibiscus Flower XML

Hibiscus Flower XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

08-hibiscus-flower.xml
Type Sample
Small file
620 B
SHA-256 4ae71ebe9f0bec672d08cc49a8a916fe7561ac93c03d9d3bf51e9b543e44cac0
Download
Data

Arctic Sky XML

Arctic Sky XML is a Extensible Markup Language sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

09-arctic-sky.xml
Type Sample
Small file
599 B
SHA-256 90c29e633d5e9ffbb71402c5727649a582944ba51a9a3d4ff296963a7df49a35
Download
Data

NASA Blue Marble XML

NASA Blue Marble XML is a Extensible Markup Language sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.

nasa-blue-marble-2012-east.xml
Type Sample
Small file
909 B
SHA-256 39372c25c4ead10c9953ef1e90ebd6b147ae9f1ef481a563eb5d02b9114940ad
Download

よくある質問

Extensible Markup Language のマジックナンバー(ファイルシグネチャ)は?

Extensible Markup Language ファイルはバイトシグネチャ 3C 3F 78 6D 6C ("<?xml") または 3C ("<") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

Extensible Markup Language のMIMEタイプは?

Extensible Markup Language のMIMEタイプは application/xml, text/xml です。

Extensible Markup Language の拡張子は?

Extensible Markup Language ファイルは .xml 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。

関連フォーマット