[ServiceContract]
public interface IParametersXMLService
{
[OperationContract, XmlSerializerFormat]
XmlNode GetCommonNode(string path);
[OperationContract, XmlSerializerFormat]
void SetCommonNode(string path, string value);
}
服务实施:
public XmlNode GetCommonNode(string path)
{
XmlDocument xml = new XmlDocument();
xml.Load(path);
XmlNode node = (XmlNode)xml.DocumentElement;
XmlNode commonNode = node.SelectSingleNode("/blabla/att);
return commonNode;
}
public void SetCommonNode(string path, string value)
{
XmlDocument xml = new XmlDocument();
xml.Load(path);
XmlNode node = (XmlNode)xml.DocumentElement;
XmlNode commonNode = node.SelectSingleNode("/blabla/att");
commonNode.Attributes["List"].Value = value;
}
GetCommonNode
正常工作并返回我的价值。
SetCommonNode
不会改变我的价值。
也许我需要在更改后保存此文件?
答案 0 :(得分:2)
如上所示,您似乎缺少XML Document保存方法调用 您应该可以通过添加以下内容来解决此问题:
xml.Save(path);
以下链接提供了更多详细信息:
http://support.microsoft.com/kb/301233