Attachment To Object in Apex

In an earlier post, Generating an XML file in Apex, we created an XML document Xmlstreamwriter class. This post we will take the XML and attach it to an object. The code to do so is pretty straight forward: