473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Append XML using ASP

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 22 '05 #1
1 1413
thomas wrote:
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,
Use Response.Write for your debugging. No need for rediredtion.
which it does but the
data has not been written to the XML file.

Any ideas where I'm going wrong.
<snip - didn't really need to see that page ... >
new_user.asp
=========

<%@ Language=JScript%>

<%

var username = Request.Form("Username")
Response.Write(username + "<BR>")
var email = Request.Form("Email")
var password = Request.Form("Password")

var xmlDoc=Server.CreateObject("MICROSOFT.FreeThreaded XMLDOM");
Nothing to do with your problem, but ... why "FreeThreaded"? Unless you're
planning on storing the resulting object in Application or Session, you
really should use the smaller, more efficient:

var xmlDoc=Server.CreateObject("msxml2.DomDocument");
xmlDoc.async="false";
xmlDoc.load(Server.MapPath("/members.xml"));
Response.Write(Server.HTMLEncode(xmlDoc.xml) + "<BR>")

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


response.Write("nodeList.length =" + nodeList.length + "<BR>")

etc. The results of the Response.Writes should tell you where the problem
is.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: yaffa | last post by:
dear folks, i'm trying to append a semicolon to my addr string and am using the syntax below. for some reason the added on of the ; doesn't work. when i print it out later on it only shows the...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
3
by: Jonathan Buckland | last post by:
Can someone give me an example how to append data without having to load the complete XML file. Is this possible? Jonathan
9
by: JMCN | last post by:
hi- i have inherited an access 97 database that keeps track of the loans. i have been running into referential intergrity problems when i try to append new loans to table. first of all is a...
1
by: Aaron | last post by:
Hello fellow programmers, I am trying to run an append/update query from code, a command button on a form initiates the queries. the format i am using is; ...
14
by: vbMark | last post by:
Greetings, This seems like it should be simple but I can't figure out how to do this. I just want to append binary file 2 on to the end of binary file 1. Sample code please? Thanks!
4
by: robboll | last post by:
When I try to use an append query from an oracle link it takes forever. I am exploring the idea of doing an append action using a pass-through query. If I have an Oracle ODBC connection to...
10
by: HYRY | last post by:
I have the following questions, I am using Python 2.4.2 19167152 #1 11306608 #1 1. the address of a.append and list.append is different, can I get the address of...
3
by: hikosj | last post by:
Hi all, I have a problem with a query in access that I cant seem to figure out. I have a form named frmRecruitment with a subform named sfrmParticipant. At the moment I am using an append query to...
4
by: franc sutherland | last post by:
Hello, I am using Access 2003. I am having trouble trapping the "can't append all the records in the append query" error message when appending data to a query from a table which is linked to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.