What output do you get from the code below? I get 2 dumped xml documents. The first one has 3 person elements under the employees node and the second one has 2 person elements under the root node.
The original company doc has only 1 person, so to me that looks like it's appending both barney and fred as employees to the company doc and not removing or replacing anything. Or did I misunderstand what you're asking? Spike START CODE *************************************** <cfxml variable="companydoc"> <company> <employees> <person> <firstname>Sam</firstname> <surname>Slate</surname> </person> </employees> </company> </cfxml> <cfxml variable="candidatesdoc"> <candidates> <person> <firstname>Fred</firstname> <surname>Flintstone</surname> <![CDATA[ test ]]> </person> <person> <firstname>Barney</firstname> <surname>Rubble</surname> </person> </candidates> </cfxml> <!--- This step returns a java object rather than a ColdFusion XML Node ---> <cfloop from="1" to="#arrayLen(candidatesdoc.candidates.person)#" index="i"> <cfset newNode = candidatesdoc.candidates.person[i].cloneNode(true)> <!--- Change the owner of the node ---> <cfset companyDoc.changeNodeOwner(newNode)> <!--- Append it to its new parent ---> <cfset companydoc.company.employees.appendChild(newNode)> </cfloop> <cfdump var="#companyDoc#"> <cfdump var="#candidatesDoc#"> *************************************************** END CODE -------------------------------------------- Stephen Milligan Code poet for hire http://www.spike.org.uk <http://www.spike.org.uk/> Do you cfeclipse? http://cfeclipse.tigris.org <http://cfeclipse.tigris.org/> ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Taco Fleur Sent: Wednesday, June 23, 2004 2:33 PM To: CFAussie Mailing List Subject: [cfaussie] RE: xml element append or something Am I just not getting it or?? Its doing a replace and not an append as far as I can tell, Barney sure has gone about. -----Original Message----- From: Stephen Milligan [mailto:[EMAIL PROTECTED] Sent: Thursday, 24 June 2004 8:28 AM To: CFAussie Mailing List Subject: [cfaussie] RE: xml element append or something Yeah, that code is copying only the first person node. If you want to copy all of them you can wrap a loop around the outside of it and treat the person node as an array: <!--- This step returns a java object rather than a ColdFusion XML Node ---> <cfloop from="1" to="#arrayLen(candidatesdoc.candidates.person)#" index="i"> <cfset newNode = candidatesdoc.candidates.person[i].cloneNode(true)> <!--- Change the owner of the node ---> <cfset companyDoc.changeNodeOwner(newNode)> <!--- Append it to its new parent ---> <cfset companydoc.company.employees.appendChild(newNode)> </cfloop> Spike -------------------------------------------- Stephen Milligan Code poet for hire http://www.spike.org.uk <http://www.spike.org.uk/> Do you cfeclipse? http://cfeclipse.tigris.org <http://cfeclipse.tigris.org/> ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Taco Fleur Sent: Wednesday, June 23, 2004 2:12 PM To: CFAussie Mailing List Subject: [cfaussie] RE: xml element append or something I was going to say "ai ai you dirty little rascal, when you get back I'll buy you a beer" until I saw you made Barney disappear!! It did a replace instead of an append. Might have to add a new empty person element first?? -----Original Message----- From: Stephen Milligan [mailto:[EMAIL PROTECTED] Sent: Thursday, 24 June 2004 1:35 AM To: CFAussie Mailing List Subject: [cfaussie] RE: xml element append or something Go have a look at my blog http://www.spike.org.uk/blog/index.cfm I posted an entry about this a week or so ago. Spike -------------------------------------------- Stephen Milligan Code poet for hire http://www.spike.org.uk <http://www.spike.org.uk/> Do you cfeclipse? http://cfeclipse.tigris.org <http://cfeclipse.tigris.org/> ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Taco Fleur Sent: Tuesday, June 22, 2004 8:02 PM To: CFAussie Mailing List Subject: [cfaussie] xml element append or something Can't seem to figure the following out. <cfxml variable="test1"> <logsummary xmlns="http://tempuri.org/logsummary.xsd"> <error uuid=""> <diagnostic occured="" firstoccurance="" lastoccurance="" fixedon=""></diagnostic> <comment></comment> <fix> <location></location> </fix> </error> </logsummary> </cfxml> <cfxml variable="test2"> <logsummary xmlns="http://tempuri.org/logsummary.xsd"> <error uuid=""> <diagnostic occured="" firstoccurance="" lastoccurance="" fixedon=""></diagnostic> <comment></comment> <fix> <location></location> </fix> </error> </logsummary> </cfxml> ************** I want to do something like structInsert(test2.logsummary, "error", test1.logsummary.error); Or structAppend(test2.logsummary, test1.logsummary.error); So I would end up with <logsummary xmlns="http://tempuri.org/logsummary.xsd"> <error uuid=""> <diagnostic occured="" firstoccurance="" lastoccurance="" fixedon=""></diagnostic> <comment></comment> <fix> <location></location> </fix> </error> <error uuid=""> <diagnostic occured="" firstoccurance="" lastoccurance="" fixedon=""></diagnostic> <comment></comment> <fix> <location></location> </fix> </error> </logsummary> is this possible? --- 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/ Register now for the 3rd National Conference on Tourism Futures, being held in Townsville, North Queensland 4-7 August - www.tq.com.au/tfconf --- 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/ --- 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/ Register now for the 3rd National Conference on Tourism Futures, being held in Townsville, North Queensland 4-7 August - www.tq.com.au/tfconf --- 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/ --- 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/ Register now for the 3rd National Conference on Tourism Futures, being held in Townsville, North Queensland 4-7 August - www.tq.com.au/tfconf --- 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/
