zoukankan      html  css  js  c++  java
  • 修改现有xml节点的值

    XmlDocument doc1 = new XmlDocument();
                    doc1.Load(Server.MapPath("~/etao/IncrementIndex.xml"));
                    //修改商品
                    XmlNodeList nodes1 = doc1.GetElementsByTagName("outer_id");
                    bool ismodif = false;
                    foreach (XmlNode xn in nodes1)//遍历任何子节点 
                    {
                        XmlElement xe = (XmlElement)xn;//将子节点类型转换为XmlElement类型 
                        if (xe.InnerText.Equals(pid))
                        {
                            xe.SetAttribute("action", "upload");//则修改该属性为“delete”
                            XmlNodeList modified = doc1.GetElementsByTagName("modified");
                            modified.Item(0).InnerText = DateTime.Now.ToString();
                            doc1.Save(Server.MapPath("~/etao/IncrementIndex.xml"));
    

    xml:
     <?xml version="1.0" encoding="utf-8" ?> 
    - <root>
      <version>1.0</version> 
      <modified>2011-7-4 9:42:54</modified> 
      <seller_id>官网</seller_id> 
      <cat_url>etao/SellerCats.xml</cat_url> 
      <dir>/etao/item/</dir> 
    - <item_ids>
      <outer_id action="upload">ID1000018452</outer_id> 
      <outer_id action="upload">ID1000018413</outer_id> 
      </item_ids>
      </root>
    

  • 相关阅读:
    Oracle文本导入器
    MSLocalDB
    使用OLE DB读写Excel
    万恶的hao123
    Php最近1个月总结
    thinkphp 3+ 观后详解 (5)
    thinkphp 3+ 观后详解 (4)
    thinkphp 3+ 观后详解 (3)
    thinkphp 3+ 观后详解 (2)
    thinkphp 3+ 观后详解 (1)
  • 原文地址:https://www.cnblogs.com/yhdkzy/p/2097164.html
Copyright © 2011-2022 走看看