Writing XML

J

Jim

Hi folks,

Could anyone help me with this one?

I want to put something on my website were people can leave their email
address to sign up for our newsletter. I've tried using JScript that writes
to an xml file.

When you click on 'enter' you are redirected to the 'done.html'. I've set
write permissions to the xml file but it doesn't seem to be working, can
anyone see what I'm doing wrong?



add.html
---------
<html>
<body>
<form name="add_email" method="post" action="add.asp">
<table>
<tr>
<td><p>Enter email</p></td>
<td><input type="text" name="email" id="email"></td>
<td><input type="submit" name="submit" value="enter"></td>
</tr>
</table>
</form>
</body>
</html>



add.asp
--------
<%@ Language=JScript%>

<%

var email = Request.Form("email")

var xmlDoc=Server.CreateObject("MICROSOFT.FreeThreadedXMLDOM");
xmlDoc.async="false";
xmlDoc.load(Server.MapPath("/test/email_address.xml"));

var nodeList = xmlDoc.getElementsByTagName("address");

if(nodeList.length > 0){

var parentNode = nodeList(0);
var addressNode = xmlDoc.createElement("address");
var emailNode = xmlDoc.createElement("email");

addressNode.text = address;
emailNode.text = email;

parentNode.appendChild(addressNode);
addressNode.appendChild(emailNode);

xmlDoc.save(Server.MapPath("/test/email_address.xml"));

}

Response.Redirect("done.html")

%>



email_address.xml
-------------------
<address>
<email>[email protected]</email>
<email>[email protected]</email>
<email>[email protected]</email>
</address>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,258
Members
46,857
Latest member
ArleenWill

Latest Threads

Top