You may find this article useful
http://xmlfiles.com/articles/michael/appendxml/default.asp
--
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver
Valleybiz Internet Design
www.valleybiz.net
"kbeveridge6778" <webforumsuser@macromedia.com> wrote
in message
news:eueahp$avi$1@forums.macromedia.com...
>I have an ASP form on my website that generates a XML
data file, but there
>are
> a few problems with it. First, when I generate the file,
it creates a new
> file
> every time a user clicks on "Submit" and I would like
the data to just be
> appended to a particular, existing XML file...how can I
append the data to
> the
> XML file? The code I am currently using is shown below.
>
> Secondly, I need to nest/repeat certain fields within
the XML file.
> Basically, I want the XML file to look like this (I
simplified the code
> for
> ease of writing, so don't bother with the syntax):
> <Recipe>
> <RecipeName>
> <SubmittedBy>
> <Ingredients>
> <Amount>
> <Unit>
> <Ingredient>
> <Description>
> <Directions>
> <Recipe>
> <RecipeName>
> etc...
> How would I create a form that would create that type of
XML file? Think
> of a
> MS Access form with linked subforms, but I don't want to
repeat more data
> than
> I have to.
>
> Any advice or help would be very appreciated!!! Also, if
you know of a
> 3-party product that might solve this for me, I am open
to that also!
>
> Thanks!!!
>
> ASP Page Code:
>
> Function saveXMLData(strPath, strFileName)
>
> 'Declare local variables.
> Dim aXMLDoca
> Dim aRootNode
> Dim aFormVar
> Dim aPI
> Dim Item
>
> 'Create an XMLDOM Object
> Set aXMLDoca = server.CreateObject("Microsoft.XMLDOM")
> aXMLDoca.preserveWhiteSpace = True
>
>
> 'Create the root node for the document
> Set aRootNode = aXMLDoca.createElement("function")
> aXMLDoca.appendChild aRootNode
>
>
> 'Iterate the Request Object for all form data
> For Each item in Request.Form
>
> 'Do not include the variable if it contains btn
> If instr(1,item,"btn") = 0 Then
> Set aFormVar =aXMLDoca.createElement(item)
> aFormVar.Text = Request.Form(item)
> aRootNode.appendChild aFormVar
> End If
>
> Next
>
>
> 'Append the processing instruction
>
> Set aPI =
aXMLDoca.createProcessingInstruction("xml","version='1.0'")
> aXMLDoca.insertBefore aPI, aXMLDoca.childNodes(0)
>
>
> 'Save the XML document.
> aXMLDoca.save strPath & "\" & strFileName
>
>
> 'Release all references.
> Set aXMLDoca = Nothing
> Set aRootNode = Nothing
> Set aFormVar= Nothing
> Set item = Nothing
> Set aPI = Nothing
> End Function
>
> dim strFullFile
>
> Function DoesFileExist(ByVal strFullFile)
> Dim objFSO
>
> 'If InStr(strFullFile, ":") = 0 Then
> 'strFileNam = Server.MapPath(strFullFile)
> 'End If
>
> Set objFSO =
Server.CreateObject("Scripting.FileSystemObject")
> DoesFileExist = objFSO.FileExists(strFullFile)
> Set objFSO = Nothing
> End Function
>
>
> Const cont_Num=10000
> Randomize
> Dim intNumber
> dim strFile
> Dim blnYes
>
> blnYes=False
>
> Do Until blnYes=True
>
> intNumber=Int((Cont_Num * Rnd)+1)
>
> 'Create a random file name so you don't write over the
same file
> strFile="Recipe"& intNumber &".xml"
>
> strFullFile="c:\inetpub\wwwroot\xmltest\" & strFile
>
> if DoesFileExist(strFullFile)=False then
> blnYes=True
> End If
> Loop
>
> ' The page starts here
> On Error Resume Next
>
> ' Save the XML Data
> SaveXMLData "c:\inetpub\wwwroot\xmltest",strFile
>