解释XML

        public static void jiexiXml(StreamWriter sw,string xmlPath)
       
        {
            util utitl = new util();
            //string xmlNodeText = "测试结点";
            XmlDocument xmlDom = new XmlDocument();
            xmlDom.Load(xmlPath);//"F:\\csharp_proj\\xml\\xijie_prod_2.xml"
            string str_xml = xmlDom.InnerXml;
            str_xml = str_xml.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");

            XmlDataDocument doc = new XmlDataDocument();
            doc.LoadXml(str_xml);

            XmlNodeList ndurl_list = doc.SelectNodes(".//url");
            if (ndurl_list != null)
            {
                foreach (XmlNode ndurl in ndurl_list)
                {
                    XmlNode ndIdent = ndurl.SelectSingleNode(".//ident");
                    string ident = ndIdent.InnerText;
                    Console.WriteLine(ident);
                    XmlNode ndBrand = ndurl.SelectSingleNode(".//brand");   //1111
                    string pinpai = ndBrand.InnerText;
                    Console.WriteLine(pinpai);
                    XmlNode ndprice = ndurl.SelectSingleNode(".//price");
                    string price = ndprice.InnerText;
                    Console.WriteLine(price);
                    XmlNode ndtitle = ndurl.SelectSingleNode(".//title");//1111
                    string producename = ndtitle.InnerText;
                    Console.WriteLine(producename);
                    XmlNode ndrefprice = ndurl.SelectSingleNode(".//refprice");
                    string refprice = ndrefprice.InnerText;
                    Console.WriteLine(refprice);
                    XmlNode ndcolor = ndurl.SelectSingleNode(".//color");//1111
                    string color = ndcolor.InnerText;
                    Console.WriteLine(color);
                    XmlNode ndChicun = ndurl.SelectSingleNode(".//availablesize");//1111
                    string chicun = ndChicun.InnerText;
                    Console.WriteLine(chicun);
                    XmlNode ndtags = ndurl.SelectSingleNode(".//tags");
                    string orifenlei = ndtags.InnerText;
                    Console.WriteLine(orifenlei);
                    XmlNode ndimage = ndurl.SelectSingleNode(".//image");
                    string image = ndimage.InnerText;
                    Console.WriteLine(image);
                    XmlNode ndcommentsurl = ndurl.SelectSingleNode(".//commentsurl");
                    string url = ndcommentsurl.InnerText;
                    Console.WriteLine(url);
                    Console.WriteLine("********************");

                    if (utitl.getselectSql(ident) == 0)
                    {
                        int text_refprice = utitl.chuli_jiage(refprice);
                        int price_1 = utitl.chuli_jiage(price);
                        string insertSql = "insert into gwkproduct (productname,price_1,refprice,ident,picurl,url,shortintro) values ('" + producename + "','" + price_1 + "','" + text_refprice + "','" + ident + "','" + image + "','" + url + "','产品名:" + producename + "品牌:" + pinpai + "颜色:" + color + "尺寸:" + chicun + "')";
                        utitl.insertSql(insertSql, sw);
                    }
                    else
                    {
                        int text_refprice = utitl.chuli_jiage(refprice);
                        int price_1 = utitl.chuli_jiage(price);
                        string updateSql = "update gwkproduct set price_1 = '" + price_1 + "',refprice='" + text_refprice + "' where ident = '" + ident + "'";
                        utitl.updateSql(updateSql, sw);
                    }

 


                }


            }
        }

转载于:https://www.cnblogs.com/px7034/archive/2010/10/08/1845914.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值