RE: xml woes
I've been following what you guys have been doing... Can you post the final code when you get it figured out? Thanks! Peter -Original Message- From: Robby L. [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 11:28 PM To: CF-Talk Subject: xml woes Importance: High ummm? I am, .. xmlsearch and xmlparse is being used in the cfscript block, and the issue is still ongoing.. Thanks though, Robby Subject: xml woes From: Peter Bagnato [EMAIL PROTECTED] Date: Mon, 17 Feb 2003 13:42:47 -0500 Thread: http://www.houseoffusion.com/cf_lists/index.cfm?method=messagesthreadid=215 87forumid=4#108995 Have you tried using any of the new XML tags in CFMX yet? Peter -Original Message- From: Robby L. [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 5:36 AM To: CF-Talk Subject: xml woes Importance: High I'm writing in hopes to see what I'm doing wrong when trying to manipulate an xml doc. The problems comes with deleting, and I'm running in loads of problems. an example of the xml doc : dropdowns drop name=abba drop_itema/drop_item drop_itemb/drop_item drop_itemc/drop_item drop_itemd/drop_item drop_iteme/drop_item /drop drop name=1221 drop_item1/drop_item drop_item2/drop_item drop_item3/drop_item drop_item4/drop_item drop_item5/drop_item /drop dropdowns !--- reading page --- cffile action=read file=C:\CFusionMX\wwwroot\Mathmotors\drop.xml variable=xmlmy cfscript drop = xmlparse(xmlmy);//xml thats parsed. dropx = drop.xmlroot;// The xml root. c_dropx = dropx.xmlchildren;// Gets the array for all of the drop down groups. count_c_dropx = arraylen(c_dropx);// Gets the count of arrays,(dropdowns.drop) Needed for a loop. hmm =abba;// fake variable tt = xmlsearch(dropx,/dropdowns/drop[@name='#hmm#']/drop_item/); /* The Search (returns an array, which will give me the info for the dropdown)*/ toto = arraylen(tt); /cfscript !--- One way I've tried --- cfoutput !--- Loop through the drop elements--- cfloop from=1 to=#arraylen(c_dropx)# index=i !--- Set the dropchildren to a variable to be able to loop over--- cfscript yes = dropx.drop[i].xmlchildren; /cfscript !--- Where the drop name's attribute equals abba then I can edit down the tree --- cfif dropx.drop[i].xmlattributes[name] is abba !--- Loop over the yes value, which would be the same as looping over the drop_item elements --- cfloop from=1 to=#arraylen(yes)# index=j !--- Set the dropchildren to a variable to be able to loop over--- cfscript yes = dropx.drop[i].xmlchildren; /cfscript !--- WHere the dropelement's text equals a delete that element @ it's index --- cfif yes[j].xmltext is a cfdump var=#j# !--- Dumps ok, .. returns the postition of audi--- cfdump var=#yes# !--- Dumps ok, .. returns the array needed --- cfscript arraydeleteat(yes, j);/*when this is in, returns the error, without it everything runs fine*/ /cfscript /cfif /cfloop /cfif /cfloop /cfoutput I've also tried ...: With using the xpath syntax (set in the upper cfscript) cfoutput cfloop from=1 to=#arraylen(tt)# index=i cfif #tt[i].xmltext# is a cfscript arraydeleteat(tt, i);/*when this is in, returns the error, without it everything runs fine*/ /cfscript /cfif /cfloop /cfoutput Both of which bail.. the first one bails without an actual error, . just the araydeleteat() being the line it error'd at. But when I looked in to the logs, It says java.lang.IndexOutOfBoundsException and searching google only gave two results, . both of which have no bearing on the situation at hand. The element at position 5 of dimension 1, of array variable TT, cannot be found is the one on the second try, and with it, the array itself is cfdumped, and there is 5 elements in the array ,I've read the docs I've double checked what I know how. What the hell am I doing wrong? Thanks for your help Robby ps I do have updater 2 installed if it has any bearing ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the
Re: xml woes
Robby, I suspect this is probably a typo, but the closing tag of your xml packet isn't a closing tag. Both of which bail.. the first one bails without an actual error, . just the araydeleteat() being the line it error'd at. But when I looked in to the logs, It says java.lang.IndexOutOfBoundsException and searching google only gave two results, . both of which have no bearing on the situation at hand. Basically, this means that CF is trying to access a element in an array, past the end of the array. eg. there are 2 elements in the array and you are trying to access the third element. Looking at your code. The reason for this is that you are using the yes variable to store an array in both your outer i loop and your inner j loop. You need to use different variables for each loop, otherwise you'll be overwriting your outer array everytime you go around your inner array. Also, I suspect that you are trying to delete the wrong bit of your array. You need to be Try this : (I warn you there maybe errors. I typed this from your code and off the top of my head without testing it) cfscript // Loop over the children of c_dropx eg. drop name=abba and drop name=1221 for (i=1; i lte arraylen(c_dropx); i=i+1) { // bung the structure for the current element into a new variable for ease thisElement = StructNew(); thisElement = c_dropx[i]; // Check the attributes of thisElement to see it is abba. if (thisElement.xmlattributes[name] is abba) // Loop over the children for thisElement, which would be the same as looping over the drop_item elements for (j=1;j lte arraylen(thisElement.xmlChildren); j=j+1) { // Store the current child structure in a variable thisChild for ease thisChild = StructNew(); thisChild = thisElement.xmlchildren[j]; if (thisChild.xmltext is a) { WriteOutput(j - thisChild.xmltextBR); arraydeleteat(thisElement.xmlchildren, j); } } } /cfscript The element at position 5 of dimension 1, of array variable TT, cannot be found is the one on the second try, and with it, the array itself is cfdumped, and there is 5 elements in the array, I've read the docs I've double checked what I know how. What the hell am I doing wrong? To be honest, I'm not sure what's up with your second bit of code. I really need to play with xml in CFMX some more, but here's the cfscript version of your code. I suspect, that you have the same problem here as you do above, where you are trying to delete the array from the wrong place in the data structure. cfscript for (i=1;i lte arraylen(tt); i=i+1) { if (tt[i].xmltext is a) { arraydeleteat(tt, i); } } /cfscript Hope some of this helps some how. Regards Stephen ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: xml woes
Have you tried using any of the new XML tags in CFMX yet? Peter -Original Message- From: Robby L. [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 5:36 AM To: CF-Talk Subject: xml woes Importance: High I'm writing in hopes to see what I'm doing wrong when trying to manipulate an xml doc. The problems comes with deleting, and I'm running in loads of problems. an example of the xml doc : dropdowns drop name=abba drop_itema/drop_item drop_itemb/drop_item drop_itemc/drop_item drop_itemd/drop_item drop_iteme/drop_item /drop drop name=1221 drop_item1/drop_item drop_item2/drop_item drop_item3/drop_item drop_item4/drop_item drop_item5/drop_item /drop dropdowns !--- reading page --- cffile action=read file=C:\CFusionMX\wwwroot\Mathmotors\drop.xml variable=xmlmy cfscript drop = xmlparse(xmlmy);//xml thats parsed. dropx = drop.xmlroot;// The xml root. c_dropx = dropx.xmlchildren;// Gets the array for all of the drop down groups. count_c_dropx = arraylen(c_dropx);// Gets the count of arrays,(dropdowns.drop) Needed for a loop. hmm =abba;// fake variable tt = xmlsearch(dropx,/dropdowns/drop[@name='#hmm#']/drop_item/); /* The Search (returns an array, which will give me the info for the dropdown)*/ toto = arraylen(tt); /cfscript !--- One way I've tried --- cfoutput !--- Loop through the drop elements--- cfloop from=1 to=#arraylen(c_dropx)# index=i !--- Set the dropchildren to a variable to be able to loop over--- cfscript yes = dropx.drop[i].xmlchildren; /cfscript !--- Where the drop name's attribute equals abba then I can edit down the tree --- cfif dropx.drop[i].xmlattributes[name] is abba !--- Loop over the yes value, which would be the same as looping over the drop_item elements --- cfloop from=1 to=#arraylen(yes)# index=j !--- Set the dropchildren to a variable to be able to loop over--- cfscript yes = dropx.drop[i].xmlchildren; /cfscript !--- WHere the dropelement's text equals a delete that element @ it's index --- cfif yes[j].xmltext is a cfdump var=#j# !--- Dumps ok, .. returns the postition of audi--- cfdump var=#yes# !--- Dumps ok, .. returns the array needed --- cfscript arraydeleteat(yes, j);/*when this is in, returns the error, without it everything runs fine*/ /cfscript /cfif /cfloop /cfif /cfloop /cfoutput I've also tried ...: With using the xpath syntax (set in the upper cfscript) cfoutput cfloop from=1 to=#arraylen(tt)# index=i cfif #tt[i].xmltext# is a cfscript arraydeleteat(tt, i);/*when this is in, returns the error, without it everything runs fine*/ /cfscript /cfif /cfloop /cfoutput Both of which bail.. the first one bails without an actual error, . just the araydeleteat() being the line it error'd at. But when I looked in to the logs, It says java.lang.IndexOutOfBoundsException and searching google only gave two results, . both of which have no bearing on the situation at hand. The element at position 5 of dimension 1, of array variable TT, cannot be found is the one on the second try, and with it, the array itself is cfdumped, and there is 5 elements in the array ,I've read the docs I've double checked what I know how. What the hell am I doing wrong? Thanks for your help Robby ps I do have updater 2 installed if it has any bearing ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribeforumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: xml woes
If I understand your question, you aren't having XML woes, you are having ArrayDeleteAt() woes. My first bit of advice when troubleshooting a problem like this would be to simplify your code. Breaking a complex problem down into smaller pieces allows you to focus on the part that's breaking without being distracted by the other stuff (like the fact that you were using XML to generate your array). Also, in a related note - you've posted a gigantic amount of code into this email, and few people on the list are likely to be willing to go through it line by line and figure out everything it's doing. That's just free unsolicited advice, though it doesn't directly solve the problem at hand. I think your problem is a pretty basic one. Essentially, you are doing this at the end of your code: cfloop from=1 to=#arraylen(tt)# index=i cfif tt[i].xmltext eq a cfset arraydeleteat(tt, i) /cfif /cfloop Looks to me like the problem is that when your array's length is evaluated at the beginning of the loop it's 5, but as soon as the cfif returns a match, you end up deleting an item from the array. This effectively changes the array's length *immediately* to 4 items. Then as the loop continues on to the 6th item, (which no longer exists - you deleted it) the server throws an exception. The java.lang.IndexOutOfBoundsException is saying that your index 5 is out of bounds because your array's only got 4 items in it. Hope that helps! -Cameron - Cameron Childress Sumo Consulting Inc. --- cell: 678-637-5072 aim: cameroncf email: [EMAIL PROTECTED] -Original Message- From: Robby L. [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 11:28 PM To: CF-Talk Subject: xml woes ummm? I am, .. xmlsearch and xmlparse is being used in the cfscript block, and the issue is still ongoing.. Thanks though, Robby Subject: xml woes From: Peter Bagnato [EMAIL PROTECTED] Date: Mon, 17 Feb 2003 13:42:47 -0500 Thread: http://www.houseoffusion.com/cf_lists/index.cfm?method=messagesth readid=21587forumid=4#108995 Have you tried using any of the new XML tags in CFMX yet? Peter -Original Message- From: Robby L. [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 5:36 AM To: CF-Talk Subject: xml woes Importance: High I'm writing in hopes to see what I'm doing wrong when trying to manipulate an xml doc. The problems comes with deleting, and I'm running in loads of problems. an example of the xml doc : dropdowns drop name=abba drop_itema/drop_item drop_itemb/drop_item drop_itemc/drop_item drop_itemd/drop_item drop_iteme/drop_item /drop drop name=1221 drop_item1/drop_item drop_item2/drop_item drop_item3/drop_item drop_item4/drop_item drop_item5/drop_item /drop dropdowns !--- reading page --- cffile action=read file=C:\CFusionMX\wwwroot\Mathmotors\drop.xml variable=xmlmy cfscript drop = xmlparse(xmlmy);//xml thats parsed. dropx = drop.xmlroot;// The xml root. c_dropx = dropx.xmlchildren;// Gets the array for all of the drop down groups. count_c_dropx = arraylen(c_dropx);// Gets the count of arrays,(dropdowns.drop) Needed for a loop. hmm =abba;// fake variable tt = xmlsearch(dropx,/dropdowns/drop[@name='#hmm#']/drop_item/); /* The Search (returns an array, which will give me the info for the dropdown)*/ toto = arraylen(tt); /cfscript !--- One way I've tried --- cfoutput !--- Loop through the drop elements--- cfloop from=1 to=#arraylen(c_dropx)# index=i !--- Set the dropchildren to a variable to be able to loop over--- cfscript yes = dropx.drop[i].xmlchildren; /cfscript !--- Where the drop name's attribute equals abba then I can edit down the tree --- cfif dropx.drop[i].xmlattributes[name] is abba !--- Loop over the yes value, which would be the same as looping over the drop_item elements --- cfloop from=1 to=#arraylen(yes)# index=j !--- Set the dropchildren to a variable to be able to loop over--- cfscript yes = dropx.drop[i].xmlchildren; /cfscript !--- WHere the dropelement's text equals a delete that element @ it's index --- cfif yes[j].xmltext is a cfdump var=#j# !--- Dumps ok, .. returns the postition of audi--- cfdump var=#yes# !--- Dumps ok, .. returns the array needed --- cfscript arraydeleteat(yes, j);/*when this is in, returns the error, without it everything runs fine*/ /cfscript /cfif /cfloop /cfif
RE: xml woes
Then as the loop continues on to the 6th item, (which no longer exists - you deleted it) the server throws an exception. ...and by 6th item I meant 5th... :) -Cameron - Cameron Childress Sumo Consulting Inc. --- cell: 678-637-5072 aim: cameroncf email: [EMAIL PROTECTED] -Original Message- From: Cameron Childress [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 18, 2003 2:10 AM To: CF-Talk Subject: RE: xml woes If I understand your question, you aren't having XML woes, you are having ArrayDeleteAt() woes. My first bit of advice when troubleshooting a problem like this would be to simplify your code. Breaking a complex problem down into smaller pieces allows you to focus on the part that's breaking without being distracted by the other stuff (like the fact that you were using XML to generate your array). Also, in a related note - you've posted a gigantic amount of code into this email, and few people on the list are likely to be willing to go through it line by line and figure out everything it's doing. That's just free unsolicited advice, though it doesn't directly solve the problem at hand. I think your problem is a pretty basic one. Essentially, you are doing this at the end of your code: cfloop from=1 to=#arraylen(tt)# index=i cfif tt[i].xmltext eq a cfset arraydeleteat(tt, i) /cfif /cfloop Looks to me like the problem is that when your array's length is evaluated at the beginning of the loop it's 5, but as soon as the cfif returns a match, you end up deleting an item from the array. This effectively changes the array's length *immediately* to 4 items. Then as the loop continues on to the 6th item, (which no longer exists - you deleted it) the server throws an exception. The java.lang.IndexOutOfBoundsException is saying that your index 5 is out of bounds because your array's only got 4 items in it. Hope that helps! -Cameron - Cameron Childress Sumo Consulting Inc. --- cell: 678-637-5072 aim: cameroncf email: [EMAIL PROTECTED] -Original Message- From: Robby L. [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 11:28 PM To: CF-Talk Subject: xml woes ummm? I am, .. xmlsearch and xmlparse is being used in the cfscript block, and the issue is still ongoing.. Thanks though, Robby Subject: xml woes From: Peter Bagnato [EMAIL PROTECTED] Date: Mon, 17 Feb 2003 13:42:47 -0500 Thread: http://www.houseoffusion.com/cf_lists/index.cfm?method=messagesth readid=21587forumid=4#108995 Have you tried using any of the new XML tags in CFMX yet? Peter -Original Message- From: Robby L. [mailto:[EMAIL PROTECTED]] Sent: Monday, February 17, 2003 5:36 AM To: CF-Talk Subject: xml woes Importance: High I'm writing in hopes to see what I'm doing wrong when trying to manipulate an xml doc. The problems comes with deleting, and I'm running in loads of problems. an example of the xml doc : dropdowns drop name=abba drop_itema/drop_item drop_itemb/drop_item drop_itemc/drop_item drop_itemd/drop_item drop_iteme/drop_item /drop drop name=1221 drop_item1/drop_item drop_item2/drop_item drop_item3/drop_item drop_item4/drop_item drop_item5/drop_item /drop dropdowns !--- reading page --- cffile action=read file=C:\CFusionMX\wwwroot\Mathmotors\drop.xml variable=xmlmy cfscript drop = xmlparse(xmlmy);//xml thats parsed. dropx = drop.xmlroot;// The xml root. c_dropx = dropx.xmlchildren;// Gets the array for all of the drop down groups. count_c_dropx = arraylen(c_dropx);// Gets the count of arrays,(dropdowns.drop) Needed for a loop. hmm =abba;// fake variable tt = xmlsearch(dropx,/dropdowns/drop[@name='#hmm#']/drop_item/); /* The Search (returns an array, which will give me the info for the dropdown)*/ toto = arraylen(tt); /cfscript !--- One way I've tried --- cfoutput !--- Loop through the drop elements--- cfloop from=1 to=#arraylen(c_dropx)# index=i !--- Set the dropchildren to a variable to be able to loop over--- cfscript yes = dropx.drop[i].xmlchildren; /cfscript !--- Where the drop name's attribute equals abba then I can edit down the tree --- cfif dropx.drop[i].xmlattributes[name] is abba !--- Loop over the yes value, which would be the same as looping over the drop_item elements --- cfloop from=1 to=#arraylen(yes)# index=j !--- Set the dropchildren to a variable to be able to loop over--- cfscript yes = dropx.drop[i].xmlchildren; /cfscript !--- WHere the dropelement's text equals a delete that element @ it's index --- cfif yes[j].xmltext