title: Best way to write arbitrary NSData into an NSXMLElement
body: <p>I am allowing for application data (it's a Mac app on 10.7) to be exported as an XML file, and one field I would like to be able to export/import to/from XML is an <code>NSData</code> field. What would be the correct/accepted way of doing this? Should I <a href="https://stackoverflow.com/questions/5999370/nsdata-to-base64">convert to base64</a> and write that string to XML?</p>
  
  <p>I would prefer not to roll my own solution, using a category, as the accepted answer to the linked question does (linking to <a href="http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html" rel="nofollow noreferrer">Matt Gallagher's solution</a>).</p>
  
  <p><strong>Update</strong></p>
  
  <p>I just discovered the <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSPropertyListSerialization_Class/Reference/Reference.html" rel="nofollow noreferrer"><code>NSPropertyListSerialization</code></a> class. I got my hopes up, but it only has static serialization methods which return <code>NSData</code> representations.</p>