Daily iOS
Networking

Parsing XML and a display transform layer

A take-home assignment asks you to download an XML feed from the company's API, show it as a list, and add a feature that swaps the English strings for made-up "Martian." How would you parse XML, rather than JSON, into a model in Swift without third parties?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Codable doesn't know XML, so use Foundation's XMLParser through its delegate (didStartElement, foundCharacters, didEndElement) as an event-based parser to assemble the model, and wrap the parser in its own type so the screen never knows it was XML.

Share a question