There are times I end up hunting longer for a piece of old code than it would take me to rewrite it. Just for my future reference and any C# programmer's amusement.
public XmlDocument DsToXml(DataSet ds) {
XmlDocument xmlDoc = new XmlDocument();
using (MemoryStream ms = new MemoryStream()) {
ds.WriteXml(ms, XmlWriteMode.WriteSchema);
ms.Position = 0;
xmlDoc.Load(ms);
}
return xmlDoc;
}