Beispiel #1
0
            /// <summary>
            /// 将XML文档对象保存为XML文件
            /// </summary>
            /// <param name="xmlDoc">XML文档对象</param>
            /// <returns>string:保存结果</returns>
            public static string SaveXmlText(XmlDocument xmlDoc)
            {
                if (xmlDoc == null)
                {
                    return(null);
                }
                try
                {
                    GBKStringWriter textWriter = new GBKStringWriter();
                    XmlTextWriter   xmlWriter  = new XmlTextWriter(textWriter);

                    xmlWriter.Formatting = Formatting.Indented;
                    if (xmlDoc != null)
                    {
                        xmlDoc.WriteTo(xmlWriter);
                    }

                    string xmlText = textWriter.ToString();
                    xmlWriter.Close();
                    textWriter.Close();
                    textWriter.Dispose();
                    return(xmlText);
                }
                catch (Exception ex)
                {
                    LogManager.Instance.WriteLog("GlobalMethods.SaveXmlText", new string[] { "xmlDoc" }
                                                 , new object[] { xmlDoc }, null, ex);
                    return(null);
                }
            }
Beispiel #2
0
            /// <summary>
            /// ��XML�ĵ����󱣴�ΪXML�ļ�
            /// </summary>
            /// <param name="xmlDoc">XML�ĵ�����</param>
            /// <returns>string:������</returns>
            public static string SaveXmlText(XmlDocument xmlDoc)
            {
                if (xmlDoc == null)
                    return null;
                try
                {
                    GBKStringWriter textWriter = new GBKStringWriter();
                    XmlTextWriter xmlWriter = new XmlTextWriter(textWriter);

                    xmlWriter.Formatting = Formatting.Indented;
                    if (xmlDoc != null)
                        xmlDoc.WriteTo(xmlWriter);

                    string xmlText = textWriter.ToString();
                    xmlWriter.Close();
                    textWriter.Close();
                    textWriter.Dispose();
                    return xmlText;
                }
                catch (Exception ex)
                {
                    LogManager.Instance.WriteLog("GlobalMethods.SaveXmlText", new string[] { "xmlDoc" }
                        , new object[] { xmlDoc }, null, ex);
                    return null;
                }
            }