brill cheers Paul, I guess the arrayappend route (as they use in the docs) is lame.
Mind you, with complex (ie deep nested packet structure), I can see the code getting a little verbose. I guess then you'd use xmlsearch() to traverse it to the point at which you want to add children... > -----Original Message----- > From: Paul Johnston [mailto:[EMAIL PROTECTED] > Sent: 16 July 2003 10:55 > To: [EMAIL PROTECTED] > Subject: RE: [ cf-dev ] adding elements to xml packets > > > Cut and paste below to test! > > Paul > > ------------code------------ > <cfxml variable="myxml"><incidents> > <error> > <date>{ts '2003-07-16 10:14:40'}</date> > <referer>some_page.cfm</referer> > <diagnostics>You experienced a general lack of > CF skills on > some_page.cfm</diagnostics> > </error> > </incidents></cfxml> > > <cfscript> > myxml.incidents.xmlchildren[2] = xmlelemnew(myxml, "error"); > myxml.incidents.xmlchildren[2].xmlchildren[1] = > xmlelemnew(myxml, > "date"); > myxml.incidents.xmlchildren[2].xmlchildren[1].xmltext = Now(); > myxml.incidents.xmlchildren[2].xmlchildren[2] = > xmlelemnew(myxml, > "referer"); > myxml.incidents.xmlchildren[2].xmlchildren[2].xmltext = > "another_page.cfm"; > myxml.incidents.xmlchildren[2].xmlchildren[3] = > xmlelemnew(myxml, > "diagnostics"); > myxml.incidents.xmlchildren[2].xmlchildren[3].xmltext = "There's > somethign wrong with this!"; > </cfscript> > > <cfdump var="#myxml#"> > ------------code------------ > > > > -----Original Message----- > > From: Rich Wild [mailto:[EMAIL PROTECTED] > > Sent: 16 July 2003 10:30 > > To: '[EMAIL PROTECTED]' > > Subject: RE: [ cf-dev ] adding elements to xml packets > > > > > > > XmlElemNew(xmlObj, childName) > > > > > > Appears to do what you want (not tested it though!) > > > > I know, thats what I'm using in the sample code I've given below! > > > > I need to find the proper syntax of doing it though, its not > > as straightforward as it may at first appear. > > > > > -----Original Message----- > > > From: Paul Johnston [mailto:[EMAIL PROTECTED] > > > Sent: 16 July 2003 10:30 > > > To: [EMAIL PROTECTED] > > > Subject: RE: [ cf-dev ] adding elements to xml packets > > > > > > > > > XmlElemNew(xmlObj, childName) > > > > > > Appears to do what you want (not tested it though!) > > > > > > Paul > > > > > > > -----Original Message----- > > > > From: Rich Wild [mailto:[EMAIL PROTECTED] > > > > Sent: 16 July 2003 10:24 > > > > To: '[EMAIL PROTECTED]' > > > > Subject: RE: [ cf-dev ] adding elements to xml packets > > > > > > > > > > > > nah, I'd like to learn the xml way of doing it. > > > > > > > > > -----Original Message----- > > > > > From: Matt Horn [mailto:[EMAIL PROTECTED] > > > > > Sent: 16 July 2003 10:23 > > > > > To: [EMAIL PROTECTED] > > > > > Subject: Re: [ cf-dev ] adding elements to xml packets > > > > > > > > > > > > > > > Regexp? > > > > > > > > > > ----- Original Message ----- > > > > > From: "Rich Wild" <[EMAIL PROTECTED]> > > > > > To: <[EMAIL PROTECTED]> > > > > > Sent: Wednesday, July 16, 2003 11:19 AM > > > > > Subject: [ cf-dev ] adding elements to xml packets > > > > > > > > > > > > > > > > To date I've only ever used <cfxml> to create fresh whole > > > > > packets of xml > > > > > > data and xmlparse to read them, but now I need to take an > > > > > existing xml > > > > > > packet (read in via cffile) and add elements to it. > > > > > > > > > > > > this is for error logging, so the structure I have is: > > > > > > > > > > > > <incidents> > > > > > > <error> > > > > > > <date>{ts '2003-07-16 10:14:40'}</date> > > > > > > <referer>some_page.cfm</referer> <diagnostics>You > > experienced a > > > > > > general lack of CF skills on some_page.cfm</diagnostics> > > > > > > </error> > > > > > > </incidents> > > > > > > > > > > > > I want to take this packet and add a new error > element to it. > > > > > > > > > > > > so far I have this: > > > > > > > > > > > > <cfscript> > > > > > > errorelem = xmlelemnew(errorpacket, "error"); > > > > > > > > > > > > errordate = xmlelemnew(errorelem, "date"); > errordate.xmlText = > > > > > > now(); arrayappend(errorelem.xmlchildren, errordate); > > > > > > > > > > > > errormsg = xmlelemnew(errorelem, "referer"); > > errormsg.xmltext = > > > > > > error.httpreferer; arrayappend(errorelem.xmlchildren, > > errormsg); > > > > > > > > > > > > errordetail = xmlelemnew(errorelem, "diagnostics"); > > > > > > errordetail.xmltext = error.diagnostics; > > > > > > arrayappend(errorelem.xmlchildren, errordetail); > > > > > > > > > > > > arrayappend(errorpacket.xmlroot.xmlchildren, errorelem); > > > > </cfscript> > > > > > > > > > > > > which gives me a java casting error (why do cfmx errors > > > > > seem to miss out > > > > > > line numbers these days?) > > > > > > > > > > > > can anyone help me with the correct syntax? > > > > > > > > > > > > much thankings... > > > > > > > > > > > > ------------------------------------------------------- > > > > > > Rich Wild > > > > > > Senior Simian > > > > > > ------------------------------------------------------- > > > > > > e-mango Tel: 01202 755 300 > > > > > > Gild House Fax: 01202 755 301 > > > > > > 74 Norwich Avenue West > > > > > > Bournemouth Mailto:[EMAIL PROTECTED] > > > > > > BH2 6AW, UK http://www.e-mango.com > > > > > > ------------------------------------------------------- > > > > > > This message may contain information which is legally > > > privileged > > > > > > and/or confidential. If you are not the intended > > > > recipient, you are > > > > > > hereby notified that any unauthorised disclosure, copying, > > > > > > distribution or use of this information is strictly > > > > prohibited. Such > > > > > > notification notwithstanding, any comments, opinions, > > > > > > information or conclusions expressed in this message > > are those > > > > > > of the originator, not of e-mango.com ltd, unless otherwise > > > > > > explicitly and independently indicated by an authorised > > > > > > representative of e-mango.com ltd. > > > > > > ------------------------------------------------------- > > > > > > > > > > > > > > > > > > -- > > > > > > ** Archive: > > > > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > > > > > > > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > > > > For additional commands, e-mail: > > > > [EMAIL PROTECTED] For > > > > > human help, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > -- > > > > ** Archive: > > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > > > [EMAIL PROTECTED] For human help, e-mail: > > > [EMAIL PROTECTED] > > > > > > > > > -- > > > ** Archive: > > http://www.mail-archive.com/dev%> 40lists.cfdeveloper.co.uk/ > > > > > > > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > > For additional commands, e-mail: > > > [EMAIL PROTECTED] For human help, e-mail: > > > [EMAIL PROTECTED] > > > > > > > > > > > -- > > ** Archive: > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > For human help, e-mail: [EMAIL PROTECTED] > > > > > > -- > > ** Archive: > http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > For human help, e-mail: [EMAIL PROTECTED] > > > > > > -- > ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > For human help, e-mail: [EMAIL PROTECTED] > -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
