Hi Chris
Yeh you need to use arrayAppend() and xmlElemNew() to append xml to an existing xml file.
your sample code could work with a few changes, but i wouldnt recommend it. ie. change <cfxml to <cfsavecontent and append the string to the file. <cfxml is creating you a new xml object complete with <?xml ...tag at the top.
but then you need to make sure each element you add is inside the root node of the xml tree...ie. add the </EMPLOYER> or whatever the root node is each time you append. ....it will get fiddly quickly.
check out the cf docs on xml: http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/xml25.htm#wp1183038
Pat
Chris Ellem wrote:
How Do I Append to a to the xml file and add more employee records?
The output i get writes the append at the bottom of the xml file and not within the structure as i would like. Any Ideas...do you use ArrayAppend or ArrayInsertAt? If anyone knows can they walk me through...thanks
Chris
###################################################################
My example code....
<cfset Path='C:\Inetpub\wwwroot\EMP\uploads\'>
<!--- SET DEFAULT VALUES ---> <CFPARAM NAME="FORM.Up_fname" DEFAULT=""> <CFPARAM NAME="FORM.Up_lname" DEFAULT=""> <CFPARAM NAME="Updated" DEFAULT="N">
<!--- SET XML VALIABLES AND STRUCTURE --->
<CFXML variable="xmlEMPLOYER">
<EMPLOYER>
<Employees><cfoutput>
<emp_code id="#XMLFormat(SESSION.employee)#">
<emp_name>#XMLFormat(FORM.Up_fname)#</stud_name>
<emp_name2>#XMLFormat(FORM.Up_lname)#</stud_name2>
<updated>#XMLFormat(Updated)#</updated>
</stud_code></cfoutput>
</Employees> </EMPLOYER>
</cfxml>
<!--- <cfdump var="#VARIABLES#"> <cfabort> --->
<cfset xml = #ToString(xmlEMPLOYER)#>
<cffile action="append" addnewline="yes" file="#Path#employees.xml" output="#xml#">
--- You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
