Click to See Complete Forum and Search --> : XML Content Deleted


IncaWarrior
01-13-2005, 05:05 PM
I have an XML file that I use to store page hits for all the pages on my site through a script in the header of each page. A couple tiems so far the XML file has just been cleared completely and I've had to restore it from a backup.

Does anyone know what causes this? Would it be a scripting problem or a person or what?

Khalid Ali
01-15-2005, 10:13 AM
tough call, though my first guess is that that there is some bug in the code that writes to XML file and in some cases it just empties it

IncaWarrior
01-15-2005, 02:47 PM
There isn't much room for it to go wrong though, it just opens and closes it.

<%
On Error Resume Next
URI = Mid(Request.ServerVariables("URL"),11)
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
xmlDoc.Load (server.mappath("pages.xml"))
Set cnode= xmlDoc.documentElement.SelectSingleNode("page[uri = '" & URI & "']")
cnode.childNodes(1).text = (CLng(cnode.childNodes(1).text)+1)
xmlDoc.save Server.Mappath("pages.xml")
%>

Khalid Ali
01-16-2005, 12:20 AM
I am not a VB coder, but just a hunch, is there a code/command that you can use to append to a file rather re-writing it?
if so try that, I am guessing that should take care of if the problem is related to write...

IncaWarrior
01-16-2005, 12:29 AM
there's an append but that adds things to the end of files.

This one opens the file, edits the appropriate node and saves the file.