ローカルでXMLファイルに保存するコードをテストしてきましたが、正常に機能しています。しかし、サーバーにアップロードしたばかりで、機能していません。パスをxmlファイルのパスに変更しましたが、それでもうまくいきません。これは私のローカルコードです...
public void AddNodeToXMLFile(string XmlFilePath, string NodeNameToAddTo)
{
//create new instance of XmlDocument
XmlDocument doc = new XmlDocument();
//load from file
doc.Load(XmlFilePath);
//create main node
XmlNode node = doc.CreateNode(XmlNodeType.Element, "Level", null);
//create the nodes first child
XmlNode mapname = doc.CreateElement("map");
//set the value
mapname.InnerText = mapsave.Value;
// add childes to father
node.AppendChild(mapname);
// find the node we want to add the new node to
XmlNodeList l = doc.GetElementsByTagName(NodeNameToAddTo);
// append the new node
l[0].AppendChild(node);
// save the file
doc.Save(XmlFilePath);
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (mapsave.Value.ToString() == "")
{
lblResult.Text = lblError.Value;
}
else
{
AddNodeToXMLFile("C:\\Users\\Glen.Robson\\Documents\\Visual Studio 2010\\Projects\\Project1\\Project1\\Scripts\\UserMaps.xml", "TileMaps");
}
}
したがって、サーバーにアップロードしたときに、AddNodeToXMLFile()のパスを次のように変更しました。
"http://www.mydomain.com/Scripts/UserMaps.xml"
しかし、これは機能しません...誰かがファイルパスがどうあるべきか教えてもらえますか?