como crear un un nuevo contacto generado desde un form con asp en un xml

geydie
06 de Junio del 2006
Hola, me preguntava si alguien save como crear un un nuevo contacto generado desde un formulario, i que se guarda en un xml desde asp.
La question es que no hay manera que me cree un nuevo contacto, me reemplaza el anterior contacto añadido, he provado infinidad de cosas i nada me da solucion, si alguien me pudiera ayudar.... seria mi angel =). Gracias.
Escrivo el codigo para que se entienda mejor:

form.htm:
<html>
<body>
<form action="gravarform.asp" method="post">
<p><b>Introdueix un nou contacte</b></p>
Nom: <input type="text" id="nom" name="nom"><br />
Cognoms: <input type="text" id="cognoms" name="cognoms"><br />
Telefon: <input type="text" id="tlf" name="tlf"><br />
Email: <input type="text" id="email" name="email"><br />
<input type="submit" id="btn_sub" name="btn_guardar" value="Guardar">
<input type="reset" id="btn_res" name="btn_borrar" value="Esborrar">
</form>
</body>
</html>

gravarform.asp:
<html>
<body>
<%
dim xmlDoc
dim rootEl,fieldName,fieldValue,fieldValue2,attID
dim p,i
dim nombasedades
Dim blnFileExists
dim strXMLFilePath
dim strFileName
strXMLFilePath = "C:Dadesgemmabdxml"
strFileName = "contactes.xml"
'nombasedades = "C:Dadesgemmabdxmlcontactes.xml"
' Do not stop if an error occurs
On Error Resume Next
'blnFileExists = xmlDoc.Load(nombasedades)
blnFileExists = xmlDoc.Load(strXMLFilePath & "" & strFileName )
'blnFileExists =xmlDoc.Load(C:Dadesgemmabdxml & "" & contactes.xml)
Set xmlDoc = server.CreateObject("Microsoft.XMLDOM")
xmlDoc.preserveWhiteSpace = true
If blnFileExists = true Then
Set rootEl = xmlDoc.documentElement
Else
' Create a root element and append it to the document
Set rootEl = xmlDoc.createElement("contacte")
xmlDoc.appendChild rootEl
' Loop through the form collection
for i = 1 To Request.Form.Count
' Eliminate button elements in the form
if instr(1,Request.Form.Key(i),"btn_")=0 then
' Create a field and a value element, and an id attribute
Set fieldName = xmlDoc.createElement("field")
Set fieldValue = xmlDoc.createElement("value")
Set attID = xmlDoc.createAttribute("id")
'Set the value of the id attribute equal to the name of the current form field
attID.Text = Request.Form.Key(i)
'Append the id attribute to the field element
fieldName.setAttributeNode attID
'Set the value of the value element equal to
'the value of the current form field
fieldValue.Text = Request.Form(i)
'Append the field element as a child of the root element
rootEl.appendChild fieldName
'Append the value element as a child of the field element
fieldName.appendChild fieldValue
'xmlDoc.documentElement.appendChild fieldValue.cloneNode(true)
end if
next
If blnFileExists = False then
'Add an XML processing instruction and insert it before the root element
Set p = xmlDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p, xmlDoc.childNodes(0)
else
End If
'Save the XML file
'xmlDoc.save( nombasedades )
xmlDoc.save (strXMLFilePath & "" & strFileName)
end if
'Release all object references
set xmlDoc=nothing
set rootEl=nothing
set fieldName=nothing
set fieldValue=nothing
set attID=nothing
set p=nothing
addNewContacttoXML "C:Dadesgemmabdxml","contactes.xml"
' Test to see if an error occurred
dim btn_guardar
btn_guardar=Request.Form("btn_guardar")
If btn_guardar<>"" Then
if err.number<>0 then
response.write("Error:La informacio no s'ha gravat correctament.")
else
%>
El contacte
<%
response.write(request.form("nom"))
response.write(" " & request.form("cognoms"))
%>
s'ha gravat correctament.
<%
end if
end if
%>
<br><a href="contactes.xml">Veure contactes</a>
</body>
</html>

Este codigo añade un nuevo <contacte> pero si ya hay alguno reemplaza el anterior.
lo que necesitaria seria esta estructura:

<?xml version="1.0" ?>
- <contacte1>
- <field id="nom">
<value>1</value>
</field>
- <field id="cognoms">
<value>1</value>
</field>
- <field id="tlf">
<value>1</value>
</field>
- <field id="email">
<value>1</value>
</field>
</contacte>
- <contacte2>etc.........

Alguien me podria echar una mano, de verdad que estaria muy agradecida, HELP PLIS!!!!! gracias de antemano.