日期:2009-03-22  浏览次数:20482 次

        static public string XMLDocumentToString(ref XMLDocument doc)

        {
            MemoryStream stream = new MemoryStream();
            XMLTextWriter writer = new XMLTextWriter(stream, null);
            writer.Formatting = Formatting.Indented;
            doc.Save(writer);

            StreamReader sr = new StreamReader(stream, System.Text.Encoding.UTF8);
            stream.Position = 0;
            string XMLString = sr.ReadToEnd();
            sr.Close();
            stream.Close();

            return XMLString;
        }