XSLT存档  

不及格的程序员-八神

 查看分类:  ASP.NET XML/XSLT JavaScripT   我的MSN空间Blog
string filePath = Form1.getProjectFilePath();
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            //xmlDoc.Load(filePath);
            using (System.IO.FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (System.IO.StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(936)))
                {
                    var strXml = sr.ReadToEnd();
                    xmlDoc.LoadXml(strXml);
                }
            }
protected void abcBankPayment(string no, string amount, string productName, string qcode)
        {
            var buildingName = productName.Split(':')[0];
            var bean = new ABCBankAccountBean();
            DataContractJsonSerializer jsonSerial = new DataContractJsonSerializer(typeof(ABCBankAccountBean));
            var result = File.ReadAllText(MapPath("~/Finance/ABCBankAccountMaping.json"), System.Text.Encoding.UTF8);
            using (MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(result)))
            {
                bean = (ABCBankAccountBean)jsonSerial.ReadObject(stream);
            }
            Building entityBuilding = bean.buildingItems.Where(exp => exp.buildingNames.Contains(buildingName)).FirstOrDefault();
            if (entityBuilding == null)
            {
                //楼盘没有农行支付配置
                getMsgLabel().Text = string.Format("楼盘'{0}'不能使用农行接口支付", buildingName);
                return;
            }
}

 

string[] arrayXmlNodeName_01 = new string[]
{
"YHX_XC_H", "YHX_XC_H1", "YHX_XC_DH", "YHX_XC_NDJ","YHX_XC_H2", "YHX_XC_H3", "YHX_XC_H4",
"YHX_XC_W", "YHX_XC_W2", "YHX_XC_L1", "YHX_XC_L2", "YHX_XC_L3"
};

string[][] arrayXmlNodeName_02 = new string[][]
{
new string[] { "YHX_XC_SHB_MAT", "YHX_XC_SHB_T" },
new string[] { "YHX_XC_LB_MAT", "YHX_XC_LB_T" },
new string[] { "YHX_XC_BB_MAT", "YHX_XC_BB_T" },
new string[] { "YHX_XC_LGJB_MAT", "YHX_XC_LGJB_T" },
new string[] { "YHX_XC_LGDB_MAT", "YHX_XC_LGDB_T" },
new string[] { "YHX_XC_XHB_MAT", "YHX_XC_XHB_T" }
};


string filePath = Form1.getProjectFilePath(); System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); //xmlDoc.Load(filePath); using (System.IO.FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (System.IO.StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(936))) { var strXml = sr.ReadToEnd(); xmlDoc.LoadXml(strXml); } } var nodeRoot = xmlDoc.SelectSingleNode("/Root/xc"); nodeRoot.RemoveAll(); Action<string> action = delegate (string ele) { var nodeTemp = xmlDoc.CreateElement(ele); Control control = this.Controls.Find(ele, true)[0]; if (control.GetType() == typeof(ComboBox)) { nodeTemp.InnerText = (control as ComboBox).SelectedValue.ToString(); } else { nodeTemp.InnerText = control.Text; } nodeRoot.AppendChild(nodeTemp); }; Action<string[]> action2 = delegate (string[] ele) { Array.ForEach<string>(ele, action); }; Array.ForEach<string>(arrayXmlNodeName_01, action); Array.ForEach<string[]>(arrayXmlNodeName_02, action2); xmlDoc.Save(filePath); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);

  

posted on 2019-12-16 14:03  不及格的程序员-八神  阅读(675)  评论(0编辑  收藏  举报