A Swift framework for converting model objects (classes and structs) to and from XML.
XMLMapper is a Swift framework that simplifies mapping XML data to native Swift objects and vice versa. It provides a declarative API for XML serialization and deserialization, reducing boilerplate when working with XML in iOS, macOS, tvOS, and watchOS applications. The framework handles complex XML structures like nested elements, attributes, and CDATA sections through extensible protocols and transforms.
Swift developers building apps for Apple platforms (iOS, macOS, tvOS, watchOS) that need to parse or generate XML data, such as those integrating with SOAP web services, legacy APIs, or XML-based data formats.
Developers choose XMLMapper for its intuitive, declarative mapping syntax using the `<-` operator, which reduces manual XML parsing code. Its unique selling points include built-in SOAP support, seamless Alamofire integration for network requests, and protocol-based design that supports custom classes, structs, and advanced transformations.
A simple way to map XML to Objects written 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.
Uses the familiar `<-` operator for mapping XML elements to properties, reducing boilerplate code as shown in the Food class example where name, price, and other fields are mapped concisely.
Handles advanced XML structures like nested elements, attributes, CDATA sections, and custom transforms, with examples for node ordering control and XMLCDATATransform for CDATA serialization.
Includes a Requests subspec for XML-encoded network requests and response mapping, demonstrated in the CD catalog example with responseXMLObject to map XML responses directly to objects.
Provides SOAPMessage and SOAPEnvelope classes for creating SOAP requests, complete with version support and easy parameter addition through subclassing, as detailed in the SOAP request examples.
The README explicitly warns that nested mapping only works for simple cases; elements with attributes or child elements require custom XMLMappable objects, adding complexity.
Version 2.0.0 introduced changes to CDATA handling that break backward compatibility, forcing developers to use XMLCDATATransform to avoid nil values during deserialization.
The Requests subspec depends on Alamofire, which increases bundle size and raises minimum deployment targets to iOS 10.0+, making it unsuitable for older app versions.
Due to Swift 4.2 changes, developers must manually manage the nodesOrder array to control XML element sequence, adding extra configuration steps as shown in the unordered elements section.