Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The index of a child element is out of range.

Status
Not open for further replies.

redoakhg

Programmer
Nov 30, 2006
38
US
I can't find any documentation on the error "The index of a child element is out of range."

Here's my code:

Code:
 <cffile action="Read" file="C:\inetpub\[URL unfurl="true"]wwwroot\ammarine\xml\inventory#dateformat(NOW(),"MM_DD_YY")#.xml"[/URL] variable="readText"> 

<!--- Create a new ColdFusion XML document object --->
<cfxml variable="XMLFile">
  <cfoutput>#readText#</cfoutput>
</cfxml>

<cfset medianodes ArrayLen(XMLFile.open_marine.broker.adverts.advert.advert_media.XmlChildren) />

<cfdump var="#medianodes#">
<cfset adverts = ArrayLen(XMLFile.open_marine.broker.adverts.XmlChildren) />
<cfloop from="1" to="#adverts#" index="i">
<cfoutput>
<b>Reference ID</b> #XMLFile.open_marine.broker.adverts.advert[i].xmlAttributes.ref#<br><br>
</cfoutput>
<cfloop from="1" to="#medianodes#" index="j">
<cfoutput>
<!---
<cfquery name="deletemedia" datasource="#datasource#">
DELETE FROM Listing_Photos
</cfquery>	
<cfquery name="inertmedia" datasource="#datasource#">
Insert Into Listing_Photos(pho_lrg,lis_id)
Values('#XMLFile.open_marine.broker.adverts.advert[i].advert_media.media[j].xmlText#','#XMLFile.open_marine.broker.adverts.advert[i].xmlAttributes.ref#')
</cfquery>
--->
<b>media</b> #XMLFile.open_marine.broker.adverts.advert[i].advert_media.media[j].xmlText#<br><br>
 </cfoutput> 
</cfloop>
</cfloop>

When I run it I get the following error:

The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.

The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
The index of a child element is out of range.
There are only 8 children under this node.
Index 9 is out of the allowed range [1-8].

The error occurred in C:\inetpub\ line 34

32 : </cfquery>
33 : --->
34 : <b>media</b> #XMLFile.open_marine.broker.adverts.advert.advert_media.media[j].xmlText#<br><br>
35 : </cfoutput>
36 : </cfloop>

You can see the XML at
Pulling my hair out! I appreciate any help i can get.
 
Disregard I fixed it. I was setting media node outside of the loop and therefor was not getting a proper count for the index.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top