Error Occurred While Processing Request
The index of a child element is out of range.
There are only "1" children under this node.
Therefore index "2" is out of the allowed range [1-1].
The error occurred in C:\Inetpub\wwwroot\guestbookRebuild\newguest.cfm: line
17
15 : <cfset temp = QueryAddRow(gbookquery,#numItems#)>
16 : <cfloop index="i" from = "1" to = #numItems#>
17 : <cfset temp = QuerySetCell(gbookquery,"firstname",
#xmlGbook.gbook.guest[i].firstname.XmlText# ,#i#)>
18 : <cfset temp = QuerySetCell(gbookquery,"lastname",
#xmlGbook.gbook.guest[i].lastname.XmlText#, #i#)>
19 : <cfset temp = QuerySetCell(gbookquery,"city",
#xmlGbook.gbook.guest[i].city.XmlText# ,#i#)>
_____
Please try the following:
* Check the ColdFusion <http://www.macromedia.com/go/proddoc_getdoc>
documentation to verify that you are using the correct syntax.
* Search the Knowledge <http://www.macromedia.com/support/coldfusion/>
Base to find a solution to your problem.
Browser
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Remote Address
127.0.0.1
Referrer
Date/Time
23-Jun-06 02:40 PM
Stack Trace (click to expand) <javascript:;>
at
cfnewguest2ecfm771652533.runPage(C:\Inetpub\wwwroot\guestbookRebuild\newgues
t.cfm:17)
coldfusion.xml.XmlChildIndexException: The index of a child element is out
of range.
at coldfusion.xml.XmlNodeList.getNode(XmlNodeList.java:115)
at coldfusion.xml.XmlNodeList.getNodeList(XmlNodeList.java:96)
at coldfusion.xml.XmlNodeList.ArrayGet(XmlNodeList.java:156)
at coldfusion.runtime.CfJspPage.ArrayGetAt(CfJspPage.java:486)
at coldfusion.runtime.CfJspPage._arrayGetAt(CfJspPage.java:516)
at
cfnewguest2ecfm771652533.runPage(C:\Inetpub\wwwroot\guestbookRebuild\newgues
t.cfm:17)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:343)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:210)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:50)
at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52)
at
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistence
Filter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.CfmServlet.service(CfmServlet.java:105)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
at
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
at
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:457
)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Here's the error
Here's the XML
<?xml version="1.0" encoding="UTF-8"?>
<gbook>
<guest>
<firstname>rthtrh</firstname>
<lastname>rth</lastname>
<city>rth</city>
<country>erh</country>
<email>rht</email>
<url>erh</url>
<comments>erh</comments>
</guest>
</gbook>
Here's the code
<cffile action="read" variable="gbookFile"
file="#ExpandPath('.')#\gbook.xml">
<cfset xmlGbook = XMLParse(gbookFile)>
<cfset numItems = ArrayLen(xmlGbook.gbook.guest.XmlChildren)>
<cfdump var="#xmlGbook#">
<cfset gbookquery = QueryNew("firstname,lastname, city, country, email, url,
comments") >
<cfset temp = QueryAddRow(gbookquery,#numItems#)>
<cfloop index="i" from = "1" to = #numItems#>
<cfset temp = QuerySetCell(gbookquery,"firstname",
#xmlGbook.gbook.guest[i].firstname.XmlText# ,#i#)>
<cfset temp = QuerySetCell(gbookquery,"lastname",
#xmlGbook.gbook.guest[i].lastname.XmlText#, #i#)>
<cfset temp = QuerySetCell(gbookquery,"city",
#xmlGbook.gbook.guest[i].city.XmlText# ,#i#)>
<cfset temp = QuerySetCell(gbookquery,"country",
#xmlGbook.gbook.guest[i].country.XmlText#, #i#)>
<cfset temp = QuerySetCell(gbookquery,"email",
#xmlGbook.gbook.guest[i].email.XmlText#, #i#)>
<cfset temp = QuerySetCell(gbookquery,"url",
#xmlGbook.gbook.guest[i].url.XmlText#, #i#)>
<cfset temp = QuerySetCell(gbookquery,"comments",
#xmlGbook.gbook.guest[i].comments.XmlText#, #i#)>
</cfloop>
<cfquery name="newGbookItem" dbType="query">
INSERT INTO gbookquery
(firstname,lastname, city, country, email, url, comments)
VALUES
('#form.lastname#','#form.firstname#','#form.city#','#form.country#','#form.
email#','#form.url#','#form.comments#')
</cfquery>
<cffile action="write" file="#ExpandPath('.')#\gbook.xml"
output="#ToString(xmlGbook)#">
All I'm trying to do is insert a new Guest node.populated with data from a
form.
Scott Stewart
ColdFusion Developer/Administrator
GlobalNet Services, Inc.
www.gnsi.com <BLOCKED::http://www.gnsi.com/>
301-770-9610 x358 (Voice)
301-770-9611 (Fax)
The information contained in this message may be privileged, confidential,
and protected from disclosure. If the reader of this message is not the
intended recipient, or any employee or agent responsible for delivering this
message to the intended recipient, you are hereby notified that any
dissemination, distribution, or copying of this communication is strictly
prohibited. If you have received this communication in error, please notify
us immediately by replying to the message and deleting it from your
computer.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244675
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54