I have read all the threads about saving node changes back to an xml file but my problem is a little different. I am loading an XML file using XML Dom into a table with a checkbox to choose a node that needs to be modified which then forwards the data to a form. The user makes the changes and submits to the code below . And before going forward I did release all references to the xml object.
'Instantiate the Microsoft XMLDOM.
Set objDom = Server.CreateObject("MSXML
2.Domdocum
ent.4.0")
call objDom.setProperty("Server
HTTPReques
t", true)
objDom.preserveWhiteSpace = True
objDom.async = false
'Call the Load Method of the XMLDOM Object.
call objDom.Load (server.MapPath("..") & "location of xml file")
If objDom.parseError.errorCod
e <> 0 Then
Response.Write "There was an error loading the xml file!<br>"
Else
Response.Write "XML loaded.<br>"
End If
'Get values from form
for each variable_name in request.form
if variable_name <> "strEditSubmit" then
Set objNode = objDom.documentElement.sel
ectSingleN
ode(variab
le_name)
If objNode is Nothing then
response.write("There is no node" & "<br>")
else
if objNode.Text <> request.form(objNode.NodeN
ame&"_oldv
alue") then
objNode.Text = request.form(variable_name
)
objDom.Save server.MapPath("..") & "path to xml file"
end if
end if
From the above I get an accessed denied error. There is nothing wrong with the folder. It has write permission set and it is working as I can write to other files in that same folder. In addition if I make a copy of the above referenced file being loaded and rename it and reference the renamed file the above code works perfectly and writes to the renamed file. I have read many threads on experts exchange but I haven't found one like this. I am very new to XML so please be patient.
I am doing something wrong but WHAT?
Start Free Trial