111,126
社区成员
发帖
与我相关
我的任务
分享
XmlDocument doc1 = new XmlDocument();
doc1.Load(Server.MapPath("~/info/consultative.xml"));
XmlDocument doc = (XmlDocument)doc1.Clone();
doc1 = null;
XmlNodeList nodeList = doc.SelectNodes("consultative/info");
foreach (XmlNode node in nodeList)
{
foreach (XmlNode nodeChild in node.ChildNodes)
{
if (nodeChild.Name == "uuid" && nodeChild.InnerText != ViewState["uuid"].ToString())
break;
if (nodeChild.Name == "answer")
nodeChild.InnerText = FCKeditor1.Value;
if (nodeChild.Name == "question")
nodeChild.InnerText = FCKeditor2.Value;
}
}
doc.Save(Server.MapPath("~/info/consultative.xml"));
doc = null;String xmlPath = Server.MapPath("~/info/consultative.xml");
XDocument xd = XDocument.Load(xmlPath);
var query = from info in xd.Descendants("info") select info;
foreach (var item in query)
{
if (item.Element("uuid").Value == ViewState["uuid"].ToString())
{
item.Element("answer").SetValue(FCKeditor1.Value);
item.Element("question").SetValue(FCKeditor2.Value);
}
else
continue;
}
xd.Save(xmlPath);