468,268 Members | 1,997 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

Writing XML

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.FreeThreaded XMLDOM");
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>a@b.com</email>
<email>c@d.com</email>
<email>c@d.com</email>
</address>
Jun 2 '06 #1
0 842

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

48 posts views Thread by Joseph | last post: by
6 posts views Thread by Sebastian Kemi | last post: by
3 posts views Thread by ishekar | last post: by
5 posts views Thread by Jeong-Gun Lee | last post: by
16 posts views Thread by Claudio Grondi | last post: by
6 posts views Thread by arne.muller | last post: by
3 posts views Thread by Barry Flynn | last post: by
89 posts views Thread by Skybuck Flying | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.