tree-sitter-xml

Tree-sitter grammars for XML and DTD documents

Library
Cargo
v0.7.0
52stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
35/100Needs Attention
Development Activity4
Maintenance20
Community44
Maturity52
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture82
Code Quality76
Innovation73
Learning Curve66

tree-sitter-xml provides tree-sitter grammars for XML and DTD, maintained under the tree-sitter-grammars organization. It parses XML documents and DTD declarations into concrete syntax trees that update incrementally as text changes, providing fast, error-tolerant parsing for editors and document tooling.

The package covers both the XML markup grammar and the accompanying DTD grammar, and ships bindings for Rust, Node, and other ecosystems along with editor query files for highlighting and structural analysis.

What You Get

  • Separate tree-sitter grammars for XML and DTD with generated C parsers
  • Language bindings including a Rust crate and an npm package
  • Highlight and query files for editor integration
  • Incremental, error-tolerant parsing suited to live editing

Common Use Cases

  • Syntax highlighting for XML and DTD in tree-sitter-based editors
  • Structural navigation and folding of XML element trees
  • Linting, formatting, and static analysis of XML documents
  • Language-server and code-intelligence backends for XML

Under The Hood

Architecture - The repository defines two grammars in grammar.js files (XML and DTD) using tree-sitter’s DSL, compiled to C parsers with external scanners that handle tags, entities, and DTD declarations. Bindings expose language() entry points for each grammar.

Tech Stack - The generated parsers are C (the repo’s primary language); grammar definitions are JavaScript. A Rust crate is published as tree-sitter-xml, and an npm package is available for Node, built with the standard tree-sitter binding toolchain.

Code Quality - Maintained under the tree-sitter-grammars organization following its conventions, with a parser test corpus and query files covering both the XML and DTD grammars.

API Design - Usage is a single call per grammar: import the binding and pass the XML or DTD language object to a tree-sitter parser. Shipped queries reduce editor glue code.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search