A Go library for decoding/encoding XML to/from map[string]interface{} (or JSON) and extracting values with dot-notation paths.
mxj is a Go library that decodes XML into map[string]interface{} (or JSON) and encodes maps or JSON back to XML. It solves the problem of handling XML data with the same flexibility as JSON in Go applications, enabling easy extraction and modification of values using path notation.
Go developers working with XML data, especially those integrating legacy XML systems, processing XML streams, or needing to manipulate XML as map structures for interoperability with JSON-based components.
Developers choose mxj because it provides a unified map-based interface for XML and JSON, supports efficient stream processing, offers extensive customization for parsing/encoding, and replaces the older x2j/j2x packages with improved performance and features.
Decode / encode XML to/from map[string]interface{} (or JSON); extract values with dot-notation paths and wildcards. Replaces x2j and j2x packages.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables seamless conversion between XML and JSON using map[string]interface{}, simplifying integration of legacy XML systems with modern JSON-based microservices, as highlighted in the motivation section.
Handles large XML streams with linear scaling, demonstrated by refactored encoder benchmarks showing efficient performance for documents with hundreds of thousands of nodes.
Offers fine-grained control over parsing with features like SetAttrPrefix(), CoerceKeysToLower(), and TrimWhiteSpace, allowing adaptation to diverse XML formats.
Supports dot-notation paths and wildcards for easy extraction and modification of nested values, as shown in methods like ValuesForPath and UpdateValuesForPath.
The README explicitly states the package is no longer actively supported as of August 2025, risking unresolved issues and lack of updates for new Go versions.
Benchmarks show decoding to maps is slower than to structs—e.g., NewMapXml is ~20% slower than NewStructXml—making it less ideal for performance-critical applications.
Attributes are prefixed with hyphens, and handling lists requires special syntax, leading to verbose and error-prone code compared to structured approaches.