[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
不会改变我的价值。也许我需要在更改后保存这个文件?