tree-sitter-xml
XML & DTD grammars for tree-sitter
What it is and what it does
tree-sitter-xml is a parser grammar for the tree-sitter parsing toolkit, providing syntax analysis for XML and DTD files. It follows the W3C XML 1.0 specification and related standards for schema and stylesheet associations. The package is a compiled grammar that integrates with tree-sitter's incremental parsing engine, allowing you to build syntax trees and perform structural analysis on XML documents.
This is a grammar distribution, not a standalone parser—it requires the tree-sitter Python bindings to actually parse files. It's designed for use in editors (Neovim, Emacs) and development tools that need to understand XML structure. With no runtime dependencies and prebuilt wheels for major platforms, installation is straightforward on supported systems.
Use it for:
- Syntax highlighting and code navigation for XML files in editor plugins or language servers
- Incremental parsing of XML documents in development tools to track structural changes
- Building AST-based analysis or transformation tools for XML configuration files
- DTD validation and schema-aware XML processing in custom parsing pipelines
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a tree-sitter parser grammar for XML and DTD files, enabling incremental parsing and syntax tree analysis of XML documents.
Yes, if you're building XML parsing or analysis tooling with tree-sitter. The grammar is permissively licensed, installs easily on modern platforms, and has no runtime dependencies. Dormant maintenance is not a blocker for a grammar package—it's stable and unlikely to need frequent updates. Install only if you already use or plan to use tree-sitter's Python bindings.
Install
tree-sitter-xml on PyPI
pip
pip install tree-sitter-xmluv
uv add tree-sitter-xmlpoetry
poetry add tree-sitter-xmlInstalling tree-sitter-xml
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for common platforms (x86_64, arm64, macOS, Linux, Windows) and Python 3.9+. Dormant maintenance status (last release 2024-11-13, 639 days ago) means no active updates, though no recent issues reported.
License in practice
MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions, provided you retain the license notice.
Quickstart
pip install tree-sitter-xml
import tree_sitter_xml
# Use with tree-sitter Python bindings to parse XML
Requires Python 3.9 or later; tree-sitter Python bindings must be installed separately to actually parse documents.
Verify before relying
- Whether tree-sitter Python bindings are automatically pulled in or must be manually installed
- Specific performance characteristics for large or deeply nested XML documents
- Completeness of DTD support and any known parsing limitations
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | dormant — 639 days since the last release |
| First released | |
| Downloads | 2,185,370/month — #3,226 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tree_sitter_xml-0.7.0-cp39-abi3-macosx_10_9_x86_64.whl; tree_sitter_xml-0.7.0-cp39-abi3-macosx_11_0_arm64.whl; tree_sitter_xml-0.7.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; tree_sitter_xml-0.7.0-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl; tree_sitter_xml-0.7.0-cp39-abi3-musllinux_1_2_x86_64.whl; tree_sitter_xml-0.7.0-cp39-abi3-win_amd64.whl; tree_sitter_xml-0.7.0-cp39-abi3-win_arm64.whl
Keywords: incremental, parsing, tree-sitter, xml
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
tree-sitter-htmlProvides an HTML grammar for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-tomlProvides a tree-sitter parser grammar for TOML…
permissive · top 5,000 on PyPI
tree-sitter-markdownProvides a tree-sitter grammar for parsing…
permissive · top 5,000 on PyPI
tree-sitter-yamlA tree-sitter parser grammar for YAML files…
permissive · top 5,000 on PyPI
tree-sitter-jsonProvides a JSON grammar parser for tree-sitter,…
permissive · top 5,000 on PyPI
tree-sitter-javaProvides a Java language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-kotlinProvides a Kotlin language grammar for…
permissive · top 5,000 on PyPI
defusedxmlDefusedxml hardens Python's standard XML…
permissive · top 1,000 on PyPI
et-xmlfileet_xmlfile writes large XML files with minimal…
permissive · top 1,000 on PyPI
xsdataxsdata generates Python dataclasses from XML…
permissive · top 5,000 on PyPI