1
[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私の価値は変わりません。たぶん、変更後にこのファイルを保存する必要がありますか?

4

1 に答える 1