...hoping this ghastly workaround will inspire pity:
<cfloop index="i" from = "1" to = #numOfNotes#>
<cftry><cfset QuerySetCell(notesQuery, "name",
#MyNotes.Notes.Page[i].XmlAttributes['name']#, #i#)>
<cfcatch></cfcatch></cftry>
<cftry><cfset QuerySetCell(notesQuery, "pageName",
#MyNotes.Notes.Page[i].XmlAttributes['pageName']#, #i#)>
<cfcatch></cfcatch></cftry>
<cftry><cfset QuerySetCell(notesQuery, 'queryString',
#MyNotes.Notes.Page[i].XmlAttributes["queryString"]#, #i#)>
<cfcatch></cfcatch></cftry>
<cftry><cfset QuerySetCell(notesQuery, 'time_Stamp',
#MyNotes.Notes.Page[i].XmlAttributes['time_Stamp']#, #i#)>
<cfcatch></cfcatch></cftry>
<cftry><cfset QuerySetCell(notesQuery, "note",
#MyNotes.Notes.Page[i].XmlText#, #i#)>
<cfcatch></cfcatch></cftry>
</cfloop>
Thanks,
Jamie
On Fri, 12 Sep 2003 12:50:12 -0400, in cf-talk you wrote:
>I'm trying to convert an XML document object to a query, but I'm
>getting stuck when I'm doing my QuerySetCell()s. If the element
>doesn't exist in that node, it bombs. However, I don't know how to
>test for the existence of the element, since isDefined() doesn't work
>on them (e.g. isDefined("MyNotes.Notes.Page[i].XmlAttributes['name']"
>bombs).
>
>Code sample follows.
>
>Thanks,
>Jamie
>
><cfscript>
> // set notesAry to array of "page" elements (which are basically
>notes elements).
> notesAry = MyNotes.Notes.XmlChildren;
> // number of notes found in the file
> numOfNotes = ArrayLen(notesAry);
> // initialize notesQuery, which will contain notes data from xml
>file
> notesQuery = QueryNew("name, pageName, queryString, timeStamp,
>note");
> // add as many records to the notesQuery as there are notes in the
>xml file
> QueryAddRow(notesQuery, #numOfNotes#);
> </cfscript>
><cfloop index="i" from = "1" to = #numOfNotes#>
> <cfscript>
> QuerySetCell(notesQuery, "name",
> #MyNotes.Notes.Page[i].XmlAttributes['name']#, #i#);
> QuerySetCell(notesQuery, "pageName",
> #MyNotes.Notes.Page[i].XmlAttributes['pageName']#, #i#);
> QuerySetCell(notesQuery, 'queryString',
> #MyNotes.Notes.Page[i].XmlAttributes["queryString"]#, #i#);
> QuerySetCell(notesQuery, 'time_Stamp',
> #MyNotes.Notes.Page[i].XmlAttributes['time_Stamp']#, #i#);
> QuerySetCell(notesQuery, "note",
> #MyNotes.Notes.Page[i].note.XmlText#, #i#);
></cfscript>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/lists.cfm?link=t:4
Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Get the mailserver that powers this list at
http://www.coolfusion.com