Added saveXml() function to allow saving xml to a file or any other output stream.