problem displaying updated XML file

wxdqz

New Member
Hi. I'm trying to create an XML guestbook. I'm using a form for the user to input his name, e-mail, message etc. an .asp file to update the xml file and an .htm file with javascript to display the xml file. The .asp file contains a <meta> tag to redirect the user from the .asp file to the guestbook.htm file. Following the submission of the form the script in the .asp file runs fine and updates the xml file but the problem is that when the xml file is accessed by guestbook.htm in appears to be accesing a cached version. For it to display the latest entry i need to access the xml file directly (<!-- m --><a class="postlink" href="http://....../guestbook.xml">http://....../guestbook.xml</a><!-- m -->), refresh it and then return to the .htm file.

Is there any way of either expiring the cached version, or forcing the browser to return to the server for the xml file, or adding something to either the .asp or .htm file to refresh the xml file? Or something different i haven't thought of?

The various scripts are below:

.asp file
<%

dim guestname
dim guestdate
dim guestsubject
dim guestmessage

set guestname = Request.Form("name")
guestdate = FormatDateTime(date(),vblongdate) 'Note that "set" is not used here
set guestsubject = Request.Form("subject")
set guestmessage = Request.Form("message")

Set objXML = server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.load(server.MapPath("guestbook.xml"))

set objguestbook = objXML.documentElement
set objentry = objXML.createElement ("entry")
objguestbook.appendChild objentry

set objentryname = objXML.createElement("name")
objentry.appendchild objentryname
objentryname.text = guestname

set objentrydate = objXML.createElement("date")
objentry.appendchild objentrydate
objentrydate.text = guestdate

set objentrysubject = objXML.createElement("subject")
objentry.appendchild objentrysubject
objentrysubject.text = guestsubject

set objentrymessage = objXML.createElement("message")
objentry.appendchild objentrymessage
objentrymessage.text = guestmessage

objXML.save(server.MapPath("guestbook.xml"))

Response.Write("<html><head><META HTTP-EQUIV=Refresh
CONTENT='5; URL=guestbook.htm'><style>body {text-align:center;
margin-top:100px; font-family:Arial, Helvetica, sans-serif;
font-size:13px;} #container {margin:0px auto; padding:5px;
width:70%; max-width:600px; border:1px solid green;
background-color:#CDF8CF;} a {color:#000000;
text-decoration:underline;} a:hover {color:#000000;
text-decoration:underline;}</style></head><body><div
id='container'><strong>Thank you for filling in the guestbook. You will
now be redirected to the guestbook...<br><br><span
style='font-size:10px'>If you are not automatically redirected click <a
href='http://www.webdeveloper.com/forum/archive/index.php/guestbook.htm'>here</a>.</span></strong></div></body></html>")

%>

.htm file
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" media="screen" href=http://www.webdeveloper.com/forum/archive/index.php/"general.css" />
<link rel="stylesheet" type="text/css" media="screen" href="guestbook.css" />
<script type="text/javascript" src="scripts.js"></script>

<script>
function callxml()
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("guestbook.xml");
var entry = xmlDoc.getElementsByTagName("entry");
document.write ("<table cellpadding=0 cellspacing=0>")
for (i=0; i<xmlDoc.documentElement.childNodes.length; i++)
{
document.write ("<tr>")
document.write ("<th colspan='2'>" + entry.item(i).childNodes[1].text + "</th>")
document.write("</tr>")
document.write("<tr>")
document.write("<td class='name' rowspan='2'>" +
entry.item(i).childNodes[0].text + "</td>")
document.write("<td class='messagehead'>Subject: " +
entry.item(i).childNodes[2].text + "<hr size='1px'></td>")
document.write("</tr>")
document.write("<tr>")
document.write("<td class='message'>" +
entry.item(i).childNodes[3].text + "<br><br></td>")
document.write("</tr>")
};
document.write ("</table>");
}
</script>
</head>

<body>
...
<script>callxml()</script>
...
</body>
 
Top