こんにちは私はxmlファイルを読み取り、特定のノードの値を変更するための次のコードを持っていますが、xmltextreaderまたはxmlreaderを使用して同じことをしたいのでdoc.Save(System.Web.HttpContext.Current.Server.MapPath("Data/Example.xml"));
、物理ファイルへの直接参照を持つステートメントを避けようとしています。
XmlDocument doc = new XmlDocument();
string xmlFile = System.Web.HttpContext.Current.Server.MapPath("Data/Example.xml");
doc.Load(xmlFile);
XmlNodeList xmlnode = doc.GetElementsByTagName("value");
xmlnode[0].ChildNodes[0].Value = 23;
doc.Save(System.Web.HttpContext.Current.Server.MapPath("Data/Example.xml"));