By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Append XML using ASP

P: n/a
This should be pretty simple for you guys. I've been trying to append values
to my XML file but I can't get it to work correctly.

index.html passes the values of a form to the new_user.asp file and I want
it to write my members.xml file.

Once the xml file has been written and saved, I coded the ASP file to
redirect to google, just to see if its working, which it does but the data
has not been written to the XML file.

Any ideas where I'm going wrong.

index.html
=======

<html>
<body>
<form action="new_user.asp" method="post" name="new_user_form">
<table>
<tr>
<td>
<table>
<tr>
<td>Username:</td>
<td><input name="Username" type="text"></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input name="Email" type="text"></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="Password" type="password"></td>
</tr>
</table>
<p><input type="submit" name="submit" value="submit"></p>
</td>
</tr>
</table>
</form>
</body>
</html>

new_user.asp
=========

<%@ Language=JScript%>

<%

var username = Request.Form("Username")
var email = Request.Form("Email")
var password = Request.Form("Password")

var xmlDoc=Server.CreateObject("MICROSOFT.FreeThreaded XMLDOM");
xmlDoc.async="false";
xmlDoc.load(Server.MapPath("/members.xml"));

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

if(nodeList.length > 0){

var parentNode = nodeList(0);
var memberNode = xmlDoc.createElement("member");
var usernameNode = xmlDoc.createElement("username");
var emailNode = xmlDoc.createElement("email");
var passwordNode = xmlDoc.createElement("password");

usernameNode.text = username;
emailNode.text = email;
passwordNode.text = password;

parentNode.appendChild(memberNode);
memberNode.appendChild(usernameNode);
memberNode.appendChild(emailNode);
memberNode.appendChild(passwordNode);

xmlDoc.save(Server.MapPath("/members.xml"));

}

Response.Redirect("http://www.google.co.uk")

%>

members.xml
=========
<members>
<member>
<username>thomas</username>
<email>th****@hotmail.com</email>
<password>123456</password>
</member>
</members>
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a


thomas wrote:

Once the xml file has been written and saved, I coded the ASP file to
redirect to google, just to see if its working, which it does but the data
has not been written to the XML file.


Could be a rights problem, make sure the account under which ASP is
exectued has the rights to access and overwrite that file.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2

P: n/a
You should also wrap this in an Application.Lock(), and Application.UnLock()
if you want to handle multiple concurrent requests safely.

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:42**********************@newsread4.arcor-online.net...


thomas wrote:

Once the xml file has been written and saved, I coded the ASP file to
redirect to google, just to see if its working, which it does but the
data has not been written to the XML file.


Could be a rights problem, make sure the account under which ASP is
exectued has the rights to access and overwrite that file.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.