title: Creating an XmlNode/XmlElement in C# without an XmlDocument?
body: <p>I have a simple class that essentially just holds some values. I have overridden the <code>ToString()</code> method to return a nice string representation.</p>
  
  <p>Now, I want to create a <code>ToXml()</code> method, that will return something like this:</p>
  
  <pre><code>&lt;Song&gt;
      &lt;Artist&gt;Bla&lt;/Artist&gt;
      &lt;Title&gt;Foo&lt;/Title&gt;
  &lt;/Song&gt;
  </code></pre>
  
  <p>Of course, I could just use a <code>StringBuilder</code> here, but I would like to return an <code>XmlNode</code> or <code>XmlElement</code>, to be used with <code>XmlDocument.AppendChild</code>.</p>
  
  <p>I do not seem to be able to create an <code>XmlElement</code> other than calling <code>XmlDocument.CreateElement</code>, so I wonder if I have just overlooked anything, or if I really either have to pass in either a <code>XmlDocument</code> or <code>ref XmlElement</code> to work with, or have the function return a String that contains the XML I want?</p>