Skip to content

feat: add XML format support (read/write)#54

Merged
alvinreal merged 1 commit intomainfrom
fix/issue-25
Feb 22, 2026
Merged

feat: add XML format support (read/write)#54
alvinreal merged 1 commit intomainfrom
fix/issue-25

Conversation

@alvinreal
Copy link
Owner

Adds XML as a fully supported format alongside JSON, YAML, TOML, and CSV.

Changes

  • Parser (from_str, from_reader): elements → maps, repeated elements → arrays, attributes with configurable prefix (@), CDATA sections, mixed content (#text), namespace prefixes preserved in key names
  • Writer (to_string): maps → elements, arrays → repeated tags, @-prefixed keys → XML attributes, XML declaration, special-character escaping
  • XmlConfig: configurable attribute prefix and root element name
  • CLI integration: -f xml / -t xml, auto-detect from .xml extension
  • Comprehensive tests: 35+ unit tests covering parsing, serialization, round-trips, attributes, CDATA, namespaces, unicode, and error cases
  • Updated the existing cli_unknown_format_error test to use a truly unknown format (protobuf) instead of xml

Fixes #25

Adds XML as a fully supported format alongside JSON, YAML, TOML, and CSV.

- Parser: elements → maps, repeated elements → arrays, attributes with
  configurable prefix (@), CDATA, mixed content (#text), namespaces
- Writer: maps → elements, arrays → repeated tags, @-prefixed keys →
  attributes, XML declaration, special-character escaping
- Configurable attribute prefix and root element name via XmlConfig
- Comprehensive tests: parsing, serialization, round-trips, edge cases
- CLI integration: -f xml / -t xml, auto-detect from .xml extension

Fixes #25
@alvinreal alvinreal merged commit 370932e into main Feb 22, 2026
6 checks passed
@alvinreal alvinreal deleted the fix/issue-25 branch February 22, 2026 04:40
@github-actions github-actions bot mentioned this pull request Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XML reader/writer

1 participant