> 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=messages&th
> > readid=21587&forumid=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_item>a</drop_item>
> > <drop_item>b</drop_item>
> > <drop_item>c</drop_item>
> > <drop_item>d</drop_item>
> > <drop_item>e</drop_item>
> > </drop>
> > <drop name="1221">
> > <drop_item>1</drop_item>
> > <drop_item>2</drop_item>
> > <drop_item>3</drop_item>
> > <drop_item>4</drop_item>
> > <drop_item>5</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=subscribe&forumid=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
                                

Reply via email to