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

 

 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          }

 

posted @ 2016-07-30 12:32  ~我心飞翔~  阅读(1060)  评论(0编辑  收藏  举报