zoukankan      html  css  js  c++  java
  • c#对XML读取

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(path+"Data\UpdateInfo\Xml\ChiGeGou.xml");
    XmlElement rootElem = xmlDoc.DocumentElement; //获取根节点
    XmlNodeList bbb = rootElem.GetElementsByTagName("tu12"); //获取tu12所有节点
    foreach(var item in bbb)
    {
    var str = ((XmlElement)item).GetElementsByTagName("item"); //获取tu12下item所有节点
    foreach (XmlElement node in str)
    {
    string up = node.GetAttribute("up");//获取up属性值
    string del = node.GetAttribute("del");
    string add = node.GetAttribute("add");
    string state = node.GetAttribute("state");

    if (!(node.GetAttribute("add").Equals("")))
    {
    if (state.Equals("") || state.Equals("0"))
    {
    string name = add.Substring(0, add.IndexOf("."));
    string url = @"image" + add;
    int result = sqlite.ExecuteNonQuery(string.Format("insert into ttc_goods_image(goods_id,image_url,thumbnail,sort_order,file_id) values(1,'{0}','{1}',1,1)", url, name));
    if(result>0)
    {
    var create_state = node.OwnerDocument.CreateAttribute("state");
    create_state.Value = "1";
    node.Attributes.Append(create_state);//设置该节点state属性

    string Updat_state = node.GetAttribute("state");

    }
    }
    }
    }
    }

    <menu2>
    <tu12>
    <!--更新-->
    <item up="11.png"></item>
    <!--删除-->
    <item del="22.png "></item>
    <!--增加-->
    <item add="JYT_Cgg10.jpg"></item>
    <item add="JYT_Cgg11.jpg"></item>
    <item add="JYT_Cgg12.jpg"></item>
    <item add="JYT_Cgg13.jpg"></item>
    <item add="JYT_Cgg14.jpg"></item>
    <item add="JYT_Cgg15.jpg"></item>
    <item add="JYT_Cgg16.jpg"></item>
    <item add="JYT_Cgg17.jpg"></item>
    <item add="JYT_Cgg18.jpg"></item>
    <item add="JYT_Cgg19.jpg"></item>
    <item add="JYT_Cgg20.jpg"></item>
    <item add="JYT_Cgg21.jpg"></item>
    <item add="JYT_Cgg22.jpg"></item>
    <item add="JYT_Cgg23.jpg"></item>
    <item add="JYT_Cgg3.jpg"></item>
    <item add="JYT_Cgg4.jpg"></item>
    </tu12>
    </menu2>

  • 相关阅读:
    LInux-crontab
    Linux权限-chmod1
    Tool_BurpSuite安装和简单使用
    python与redis交互(四)
    Flask_环境部署(十六)
    Nginx_配置文件nginx.conf配置详解
    Tool_linux环境安装python3和pip
    Nginx_全局命令设置
    Linux_无法解析域名
    VMware_克隆机器后主机Ping不同虚拟机,虚拟机能Ping通主机
  • 原文地址:https://www.cnblogs.com/wlwenjie/p/5044489.html
Copyright © 2011-2022 走看看