码迷,mamicode.com
首页 > 其他好文 > 详细

更改XML文件内容(发票管理软件)

时间:2016-07-30 13:30:46      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:

 

 1  public void AlterXml(string pathstring)//List<string> name,List<string> value)
 2         {
 3             try
 4             {
 5                 XmlDocument xmldoc = new XmlDocument();
 6                 xmldoc.Load(pathstring);
 7                 XmlNodeList rootnode = xmldoc.DocumentElement.ChildNodes;
 8            //     XmlNodeList xmlnodel = rootnode.ChildNodes;
 9 
10                 foreach (XmlNode xn in rootnode)
11                 {
12                     if (xn.Name.ToString() == "INVOICE_CUSTOMER_INFO")
13                         xn.InnerText = "CUSTOMER_CODE~~CUSTOMER_NAME~~CUSTOMER_MNE~~CUSTOMER_TAX~~CUSTOMER_ADDRESS~~CUSTOMER_BANK~~~~CUSTOMER_NOTES~~";
14                     if (xn.Name.ToString()=="INVOICE_PRODUCT_INFO")
15                         xn.InnerText = "ITEM_CODE~~ITEM_NAME~~ITEM_MNE~~TAX_NB~~TAX_RATE~~ITEM_STAND~~ITEM_UNIT~~ITEM_PRICE~~TAX_FLAG~~~~~~GOODSTAXNO~~~~~~~~~~";
16                  
17 
18                 }
19                 xmldoc.Save(pathstring);
20                // return "";
21                 }
22                 catch (Exception e)
23                 {
24                     StreamWriter sw = new StreamWriter(Application.StartupPath + "log.txt", true);
25                     sw.Write(System.DateTime.Now.ToString("yyyMMddddss") + "   " + e.ToString());
26                     sw.Close();
27 
28                 }
29            
30          }

 

更改XML文件内容(发票管理软件)

标签:

原文地址:http://www.cnblogs.com/huyun/p/5720697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!