用程序这样就可以了
XmlDocument oXMLDOM = new XmlDocument();
XmlNode oPiNode =
oXMLDOM.CreateProcessingInstruction("xml","version='1.0' encoding='gb2312'");
oXMLDOM.AppendChild(oPiNode);
MessageBox.Show(oXMLDOM.OuterXml);
XmlDocument oXMLDOM = new XmlDocument();
XmlNode oPiNode =
oXMLDOM.CreateProcessingInstruction("xml","version='1.0' encoding='gb2312'");
oXMLDOM.AppendChild(oPiNode);
MessageBox.Show(oXMLDOM.OuterXml);
xmldoc.LoadXml("<root />");
MessageBox.Show(xmldoc.InnerXml);XmlDeclaration xmldeclare = xmldoc.CreateXmlDeclaration("1.0", "Utf-8", "yes");
xmldoc.InsertBefore(xmldeclare, xmldoc.DocumentElement);
MessageBox.Show(xmldoc.InnerXml);