protected void savetopic_Click(object sender, EventArgs e) { #region 保存主题修改 XmlDocumentExtender doc = new XmlDocumentExtender(); doc.Load(configPath); XmlNodeList topiclistNode = doc.SelectNodes("/Aggregationinfo/Aggregationpage/Website/Forum/Topiclist/Topic"); XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode topic in topiclistNode) { topicvisitor.SetNode(topic); if (topicvisitor["topicid"] == topicid.Value) { topicvisitor["topicid"] = topicid.Value; topicvisitor["title"] = tbtitle.Text; topicvisitor["poster"] = poster.Text; topicvisitor["postdatetime"] = postdatetime.Text; XmlCDataSection shortDes = doc.CreateCDataSection("shortdescription"); shortDes.InnerText = shortdescription.Text; topicvisitor.GetNode("shortdescription").RemoveAll(); topicvisitor.GetNode("shortdescription").AppendChild(shortDes); break; } } doc.Save(configPath); Response.Redirect("aggregation_editforumaggset.aspx"); #endregion }
private void ModifyNode(XmlDocumentExtender doc,string topicPath) { XmlNodeList topiclistNode = doc.SelectNodes(topicPath); XmlNodeInnerTextVisitor topicvisitor = new XmlNodeInnerTextVisitor(); foreach (XmlNode topic in topiclistNode) { topicvisitor.SetNode(topic); if (topicvisitor["topicid"] == topicid.Value) { topicvisitor["topicid"] = topicid.Value; topicvisitor["title"] = title.Text; topicvisitor["poster"] = poster.Text; topicvisitor["postdatetime"] = postdatetime.Text; XmlCDataSection shortDes = doc.CreateCDataSection("shortdescription"); shortDes.InnerText = shortdescription.Text; topicvisitor.GetNode("shortdescription").RemoveAll(); topicvisitor.GetNode("shortdescription").AppendChild(shortDes); break; } } }