Start by defining the XML source, wrapping it in Data, and passing it to XMLDocument.
The initialiser is failable: it returns nil when libxml2 cannot salvage the input even with error recovery enabled. Handling this with guard gives you a safe entry point into the rest of the code.