Esempio n. 1
0
        private void comboBox_xmlFile_encoding_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strEncoding = this.comboBox_xmlFile_encoding.Text;

            string      strError = "";
            XmlDocument dom      = new XmlDocument();

            try
            {
                dom.LoadXml(this.textBox_xmlEditor_content.Text);
            }
            catch (Exception ex)
            {
                strError = "XML格式不合法: " + ex.Message;
                goto ERROR1;
            }

            if (DomUtil.GetDomEncodingString(dom) != this.comboBox_xmlFile_encoding.Text)
            {
                bool bRet = DomUtil.SetDomEncodingString(dom, this.comboBox_xmlFile_encoding.Text);
                if (bRet == true)
                {
                    this.textBox_xmlEditor_content.Text = DomUtil.GetIndentXml(dom);
                }
            }

            return;

ERROR1:
            MessageBox.Show(this, strError);
        }