假设我理解正确using System.Xml.Linq; XDocument xDoc = XDocument.Load(@".....\test.xml"); string xDocString = xDoc.ToString(SaveOptions.None);