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);
}
}
}
}