/// <summary>
/// 删除商品xml提交动作
/// </summary>
/// <param name="ids">id集合</param>
public void etao_delProductXml(string ids)
{
XmlDocument doc1 = new XmlDocument();
doc1.Load(Server.MapPath("~/etao/IncrementIndex.xml"));
XmlNodeList nodes1 = doc1.GetElementsByTagName("outer_id");
string[] strArray = ids.Split(',');
for (int i = 0; i < strArray.Length; i++)
{
string xmlpath = base.Server.MapPath("~/etao/item/" + strArray[i] + ".xml");
try
{
if (System.IO.File.Exists(xmlpath))
{
File.Delete(xmlpath);
}
foreach (XmlNode xn in nodes1)//遍历任何子节点
{
XmlElement xe = (XmlElement)xn;//将子节点类型转换为XmlElement类型
if (xe.InnerText.Equals(strArray[i]))
{
xe.SetAttribute("action", "delete");//则修改该属性为“delete”
XmlNodeList modified = doc1.GetElementsByTagName("modified");
modified.Item(0).InnerText = DateTime.Now.ToString();
doc1.Save(Server.MapPath("~/etao/IncrementIndex.xml"));
}
}
}
catch
{
}
}
}
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>
<outer_id action="delete">ID1000018312</outer_id>
</item_ids>
</root>