A Swift library for encoding and decoding XML using Codable protocols.
XMLCoder is a Swift library that provides XMLEncoder and XMLDecoder implementations, enabling seamless conversion between XML and Swift's Codable types. It solves the problem of cumbersome XML parsing in Swift by offering a type-safe, protocol-oriented approach similar to JSONEncoder and JSONDecoder.
Swift developers working with XML data on Apple platforms (iOS, macOS, tvOS, watchOS), Linux, or Windows, particularly those building server-side applications with frameworks like Vapor.
Developers choose XMLCoder for its deep integration with Swift's Codable protocols, extensive feature set (including namespace handling, property wrappers, and Combine support), and strong cross-platform compatibility, making it the most comprehensive XML coding solution in the Swift ecosystem.
Easy XML parsing using Codable protocols in Swift
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Leverages Swift's native Codable protocols, providing a familiar and type-safe API similar to JSONEncoder/Decoder, as shown in the basic example with struct Note.
Supports complex XML structures through dynamic node coding, namespace handling, property wrappers, and choice element coding, detailed in the README's advanced sections.
Works on all major Apple platforms, Linux, and Windows, with installation options for Swift Package Manager, CocoaPods, and Carthage, indicated by platform badges.
Conforms to TopLevelEncoder and TopLevelDecoder, enabling seamless integration with Apple's Combine for reactive programming, with examples provided in the README.
Handling edge cases like mixed attributes/elements or namespaces requires implementing additional protocols like DynamicNodeEncoding, adding boilerplate code compared to simpler libraries.
As an object-based coder, it may be less efficient for parsing very large XML files compared to event-driven parsers, a limitation inherent in its type-safe design.
Lacks native support for XML schema validation or DTD enforcement, requiring external tools or custom code for compliance checks, which is not mentioned in the features.
Tied to Swift's compiler stability; the README warns against using Xcode 11.2 due to crashes from compiler bugs, indicating potential fragility with specific toolchain versions.