Oak XML Parser
High-performance incremental XML parser for the oak ecosystem with flexible configuration, optimized for data processing and document parsing.
🎯 Overview
Oak of xml is a robust parser for XML, designed to handle complete XML syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for data processing and document parsing.
✨ Features
- Complete XML Syntax: Supports all XML features including modern specifications
- Full AST Generation: Generates comprehensive Abstract Syntax Trees
- Lexer Support: Built-in tokenization with proper span information
- Error Recovery: Graceful handling of syntax errors with detailed diagnostics
🚀 Quick Start
Basic example:
use XmlParser;
📋 Parsing Examples
Document Parsing
use ;
let parser = new;
let xml_content = r#"
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<title>XML Developer's Guide</title>
</book>
</catalog>
"#;
let document = parser.parse_document?;
println!;
Element Parsing
use ;
let parser = new;
let xml_content = r#"
<person age="30">
<name>John Doe</name>
<email>john@example.com</email>
</person>
"#;
let element = parser.parse_element?;
println!;
println!;
🔧 Advanced Features
Token-Level Parsing
use ;
let parser = new;
let tokens = parser.tokenize?;
for token in tokens
Error Handling
use XmlParser;
let parser = new;
let invalid_xml = r#"
<?xml version="1.0"?>
<root>
<item>Missing closing tag
</root>
"#;
match parser.parse_document
🏗️ AST Structure
The parser generates a comprehensive AST with the following main structures:
- Document: Root container for XML documents
- Element: XML elements with tags and attributes
- Attribute: Element attributes with name-value pairs
- Text: Text content nodes
- Comment: XML comments
- ProcessingInstruction: XML processing instructions
📊 Performance
- Streaming: Parse large XML files without loading entirely into memory
- Incremental: Re-parse only changed sections
- Memory Efficient: Smart AST node allocation
- Fast Recovery: Quick error recovery for better IDE integration
🔗 Integration
Oak of xml integrates seamlessly with:
- Data Processing: Extract data from XML documents
- Configuration Files: Parse XML configuration files
- Web Services: Process XML API responses
- IDE Support: Language server protocol compatibility
- Document Processing: XML parsing for document management
📚 Examples
Check out the examples directory for comprehensive examples:
- Complete XML document parsing
- Element and attribute analysis
- Data extraction and transformation
- Integration with development workflows
🤝 Contributing
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.