XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlText); //plu.xml 编码是ANSI的。否则称上品名是乱码 XmlElement xeRoot = xmlDoc.DocumentElement; XmlDeclaration xdl = xmlDoc.CreateXmlDeclaration("1.0", "gb2312", "yes"); xmlDoc.InsertBefore(xdl, xeRoot); xmlDoc.Save(fileFullName);