XML to Objective C

Generate Objective-C model classes from an XML sample.

XML to Objective-C – Model classes for iOS and macOS

The XML to Objective-C converter produces a header (.h) and implementation (.m) for every element type in your XML sample. Each class is an NSObject subclass with typed @property declarations, nullability annotations inside NS_ASSUME_NONNULL blocks, and two methods: +fromDictionary: and -toDictionary.

How XML maps to types

XML has no native types, so the converter reads every element and attribute value and infers one: whole numbers become integers, decimals become floating-point numbers, true/false become booleans, and everything else stays a string. Attributes are kept apart from child elements (they appear as @name keys internally), an element that has both attributes and text gets a dedicated text field, and repeated sibling elements such as several item nodes become a list. Namespace prefixes are stripped from names so ns:customer and customer produce the same type.

From XML to objects

Objective-C apps usually turn XML into an NSDictionary first — with a small NSXMLParser delegate, XMLDictionary, or a similar helper that stores attributes under @name keys and text under #text. The generated fromDictionary: reads exactly those keys, checks types with isKindOfClass:, builds nested objects, and turns repeated elements into NSArray instances of the right class. Numbers and booleans become NSInteger, double and BOOL when they are always present, and NSNumber * when they are optional.

Naming

Property names are camelCase. Names that clash with NSObject methods are renamed — id becomes identifier and description becomes descriptionText — while the dictionary keys keep the original XML names. Add a class prefix such as ABC to follow Apple's naming guidelines and avoid collisions.

Use cases

Maintaining an older iOS app that consumes an XML or SOAP backend, parsing plist-like configuration, or bridging XML data into Swift code through an Objective-C model layer.

Tips

Split the output into separate .h and .m files at the marked comments, and make sure your XML-to-dictionary helper always returns arrays for repeated elements.

Generate the same models from JSON with JSON to Objective C or inspect your input in the XML Viewer.

Frequently Asked Questions

No. The XML is parsed and converted by JavaScript running in your browser tab. Nothing is sent to a server, so internal feeds, SOAP payloads and configuration files stay on your machine.

Yes. Properties use strong, copy and assign attributes that assume Automatic Reference Counting, which is the default for all modern Xcode projects.

Yes. Add the header to your bridging header; the nullability annotations make optional properties appear as Swift optionals.

id is an Objective-C type and description is an NSObject method, so they would break or shadow existing APIs. The property is renamed, but the dictionary key stays the original element name.