Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Write/Append XML

Thread Tools

Write/Append XML

Posts: n/a
I have the below form and I want the contents of the fields to be passed to
an ASP file which then writes them to an XML file. I've used a version of
this before, I then changed it but now it doesn't work. Any ideas?

<title>New User</title>
<link href="mystyle.css" rel="stylesheet" type="text/css">
<form action="new_user.asp" method="post" name="new_user_form">
<table class = "one">
<table class = "one">
<td><input name="user" id="user" type="text" ></td>
<td><input name="pass" id="pass" type="text"></td>
<p><input type="submit" name="Submit" value="Confirm Details"></p>
<p><a href="index.html">Return to Login Page</a></p>

<%@ Language="VBScript" %>


dim objDom, fileExists, objFieldValue, objPI, nodes, path

Set objDom = server.CreateObject("Microsoft.XMLDOM")
objDom.preserveWhiteSpace = True

fileExists=objDom.Load(Server.MapPath("users.xml") )
If fileExists = True Then
Set objRoot = objDom.documentElement
Set objRoot = objDom.createElement("members")
objDom.appendChild objRoot
End If

Set objRecord = objDom.createElement("member")
objRoot.appendChild objRecord

Set objFieldValue = objDom.createElement("username")
objFieldValue.Text = Request.Form("user")
objRecord.appendChild objFieldValue

Set objFieldValue = objDom.createElement("password")
objFieldValue.Text = Request.Form("pass")
objRecord.appendChild objFieldValue

set xmlDocument=CreateObject("MSXML2.FreeThreadedDOMDo cument")

path = "members[user='" & lcase(Request.Form("user")) & "']"
set nodes = xmlDocument.selectNodes(path)
If nodes.length = 0 Then

If fileExists = False Then
Set objPI=objDom.createProcessingInstruction("xml", "version='1.0'")
objDom.insertBefore objPI, objDom.childNodes(0)
End If
End If"users.xml"))



<?xml version="1.0"?>

Reply With Quote
Andy Dingley
Posts: n/a
On Mon, 16 May 2005 23:40:25 GMT, "thomas" <(E-Mail Removed)>

>I have the below form and I want the contents of the fields to be passed to
>an ASP file which then writes them to an XML file. I've used a version of
>this before, I then changed it but now it doesn't work. Any ideas?

Diff it against the one that worked ?

(Oh, and you're being very free and easy with user-supplied data values.
Never trust a user.)

Really though I'd bin the whole page. Use a database, not XML. There's
a whole pile of multi-user locking problems you need to think about here
and your big monolithic XML file is just ignoring them all. This isn't
code that's anything like "web-ready" and it's more trouble to make it
so than it would be to just switch to a database.

XML isn't a database. It works with "documents", units of work that
roughly represent one transaction. The database analogy is the row of a
view (or maybe a view), not a table and certainly not a whole database.
You're performing a task here which will pretty much never need to
access the entire user list, just a single user - yet choosing XML
forces you to load, edit and save the whole set every time. That's just
a bad idea and fixing it (although possible) is harder than it would be
to do it by an easier method in the first place.

You never _have_ to use XML.

Cats have nine lives, which is why they rarely post to Usenet.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM
embedding xml in xml as non-xml :) Mark Van Orman XML 5 09-15-2004 05:57 AM
What XML technologies to learn first for "XML Processing" and "XML Mapping"? Bomb Diggy Java 0 07-28-2004 07:26 AM
Help on including one XML document within another XML document using XML Schemas Tony Prichard XML 0 12-12-2003 03:18 PM