title: Convert a DOM Node or Document to XML in JavaScript
body: <p>Say you in JavaScript are handed a single DOM element or Document (for example window.document), how would you turn that into valid XML?</p>
  
  <p>More specifically for my example, I have a web page that display's an SVG, this SVG has a lot of JavaScript to allow interaction. It's a graph display that let's you zoom in the graph and even make some transformations. Now the users off this want's to have a "Save image" button. The way I imagine doing this is to take the document node for the SVG element, and convert it into XML, then send that to the server, which then returns a page with the SVG document, or a PNG image.</p>
  
  <p>This is all running on FireFox (which is currently a requirement for the users, though it works fine in Safari and Chrome as well). In firefox in the web page, I have included the SVG document as an Object element. In javascript I can access that objects contentDocument, that refers to the root off the XML page. It contains XML version, a Document tag, and the root svg tag with all attributes.</p>
  
  <p>Maybe someone has already solved this, so I can copy their code. Perhaps someone knows where to look in firebug to achieve this. Or maybe there are already DOM methods for this.</p>