62,074
社区成员
发帖
与我相关
我的任务
分享
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(new System.IO.StringReader(clickCount));
XmlNode node = xmlDoc.SelectSingleNode("/data");
XmlNodeList nodeList = xmlDoc.SelectNodes("/data/webmethod");
for (int i = 0; i < nodeList.Count; i++)
{
if (webmethod.Trim() == nodeList[i].Attributes["methodname"].Value.ToString().Trim())
{
nodeList[i].Attributes["clickcount"].Value = (int.Parse(nodeList[i].Attributes["clickcount"].Value.ToString()) + 1).ToString();
}
if (webmethod.Trim() != nodeList[i].Attributes["methodname"].Value.ToString().Trim())
{
nodeList[i].Attributes["clickcount"].Value = nodeList[i].Attributes["clickcount"].Value.ToString();
}
else
{
XmlElement xesub = xmlDoc.CreateElement("webmethod");
xesub.SetAttribute("methodname", webmethod);
xesub.SetAttribute("clickcount", "1");
node.AppendChild(xesub);
}
}
xmlDoc.Save("data.config");
FileStream fs = new FileStream("data.config", FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(fs);
string outerXml = reader.ReadToEnd();
reader.Close();
fs.Close();
return outerXml;
for (int i = 0; i < nodeList.Count; i++)
{
if (webmethod.Trim() == nodeList[i].Attributes["methodname"].Value.ToString().Trim())
{
nodeList[i].Attributes["clickcount"].Value = (int.Parse(nodeList[i].Attributes["clickcount"].Value.ToString()) + 1).ToString();
XmlElement xesub = xmlDoc.CreateElement("webmethod");
xesub.SetAttribute("methodname", webmethod);
xesub.SetAttribute("clickcount", "1");
node.AppendChild(xesub);
}
else
{
nodeList[i].Attributes["clickcount"].Value = nodeList[i].Attributes["clickcount"].Value.ToString();
}
}
if (webmethod.Trim() == nodeList[i].Attributes["methodname"].Value.ToString().Trim())
{
nodeList[i].Attributes["clickcount"].Value = (int.Parse(nodeList[i].Attributes["clickcount"].Value.ToString()) + 1).ToString();
XmlElement xesub = xmlDoc.CreateElement("webmethod");
xesub.SetAttribute("methodname", webmethod);
xesub.SetAttribute("clickcount", "1");
node.AppendChild(xesub);
}
else
{
nodeList[i].Attributes["clickcount"].Value = nodeList[i].Attributes["clickcount"].Value.ToString();
}
<data>
<webmethod methodname="ExistConfig" clickcount="5">
</webmethod>
<webmethod methodname="GetConfigBySessionKey" clickcount="2" />
<webmethod methodname="ExistConfig" clickcount="1" />
</data>