title: How to use custom XML attributes with Swiften
body: <p>I'm currently developing a XMPP-based system that consists of an iOS app, an ejabberd server, and a standalone client that acts as a controller that can receive requests from users and take actions accordingly (I'm aware of IQ stanzas, but developing ejabberd modules in Erlang is way out of my league.)</p>
  
  <p>For the iOS app I'm using XMPPFramework, and for the controller I've chosen Swiften, as it was the most recommended C++ library around here. Since this is more than a plain messaging system, I've found the need to include some custom attributes in the messages, like the following:</p>
  
  <pre><code>&lt;message type="chat" 
           to="controller@example" 
           custom_attribute_1="Value 1"
           custom_attribute_2="Value 2"
      &lt;subject&gt;Subject&lt;/subject&gt;
      &lt;body&gt;Body&lt;/body&gt;
      &lt;thread&gt;Thread&lt;/thread&gt;
  &lt;/message&gt;
  </code></pre>
  
  <p>This was very easy to do with XMPPFramework, but I've failed miserably at trying to read the custom attributes with Swiften, let alone generate a custom message.</p>
  
  <p>I've tried two approaches. The first one was to get the Raw XML from the message and get the attributes using a boost XML Parser, but I haven't even been able to get the <code>RawXMLPayload</code> out of the message.</p>
  
  <p>The second approach, which I thought would be more straightforward in the end, was to analyze the Swift/Swiften code to find out how they manage the whole XML-to-object conversion. I know they use the <code>AttributeMap</code> class, but I have no idea how those objects come to be, so no luck there either.</p>
  
  <p>How can I accomplish this? Can it be done using Swiften?</p>