title: Custom output XML (with attributes) with TastyPie?
body: <p>I apologize in advance if this is not the correct area to post this, but I can't seem to find any help in the docs or on Stack Overflow.  TastyPie is awesome, and I've been able to get very close to the desired XML output.  However, the problem arises when I want to have a custom attribute on a node. I can't seem to find a way to do this with TastyPie barring writing the API from scratch.  </p>
  
  <p>For example let's say I have this sample output from TastyPie (excerpt only):</p>
  
  <pre><code>&lt;media type="list"&gt;
  &lt;object type="hash"&gt;
      &lt;filename&gt;filename.mp4&lt;/filename&gt;
      &lt;id type="integer"&gt;62&lt;/id&gt;
      &lt;name&gt;AE&lt;/name&gt;
      &lt;position type="integer"&gt;0&lt;/position&gt; 
      &lt;product type="integer"&gt;65&lt;/product&gt;
      &lt;type&gt;video&lt;/type&gt;
  &lt;/object&gt;
  &lt;object type="hash"&gt;
      &lt;filename&gt;filename.jpg&lt;/filename&gt;
      &lt;id type="integer"&gt;63&lt;/id&gt;
      &lt;name&gt;Some Name&lt;/name&gt;
      &lt;position type="integer"&gt;1&lt;/position&gt; 
      &lt;product type="integer"&gt;65&lt;/product&gt;
      &lt;type&gt;image&lt;/type&gt;
  &lt;/object&gt;
  &lt;/media&gt;
  </code></pre>
  
  <p>What I really need is this (notice I want to add a custom attribute (or attributes) to a node - in this case, filename has a attribute):</p>
  
  <pre><code>&lt;media type="list"&gt;
  &lt;object type="hash"&gt;
      &lt;filename type="video"&gt;filename.mp4&lt;/filename&gt;
      &lt;id type="integer"&gt;62&lt;/id&gt;
      &lt;name&gt;Some Name&lt;/name&gt;
      &lt;position type="integer"&gt;0&lt;/position&gt; 
      &lt;product type="integer"&gt;65&lt;/product&gt;
  &lt;/object&gt;
  &lt;object type="hash"&gt;
      &lt;filename type="image"&gt;filename.jpg&lt;/filename&gt;
      &lt;id type="integer"&gt;63&lt;/id&gt;
      &lt;name&gt;Another Name&lt;/name&gt;
      &lt;position type="integer"&gt;1&lt;/position&gt; 
      &lt;product type="integer"&gt;65&lt;/product&gt;
  &lt;/object&gt;
  &lt;/media&gt;
  </code></pre>
  
  <p>Or even better, this:</p>
  
  <pre><code>&lt;media type="list"&gt;
      &lt;object type="hash" format="video" id="62" position="0" product_type="65" filename="filename.mp4" name="Some Name" /&gt;
      &lt;object type="hash" format="image" id="63" position="1" product_type="65" filename="filename.jpg" name="Another Name" /&gt;
  &lt;/media&gt;
  </code></pre>
  
  <p>What would be required in order to customize the XML serializer to add attributes where needed? <strong>Or even better, tell it which values can be safely described as attributes rather than as a node?</strong> I don't understand how to add an attribute to the output XML.  Any help is greatly appreciated.  Thanks in advance.</p>