Expand description
This crate provides XML and DTD language support for the tree-sitter parsing library.
Typically, you will use the LANGUAGE_XML constant to add this language to a tree-sitter Parser, and then use the parser to parse some code:
use tree_sitter::Parser;
let code = r#"
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
"#;
let mut parser = Parser::new();
let language = tree_sitter_xml::LANGUAGE_XML;
parser
.set_language(&language.into())
.expect("Error loading XML parser");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());
Constantsยง
- The syntax highlighting queries for DTD.
- The content of the
node-types.json
file for DTD. - The tree-sitter
LanguageFn
for the DTD grammar. - The tree-sitter
LanguageFn
for the XML grammar. - The syntax highlighting queries for XML.
- The content of the
node-types.json
file for XML.