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
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics.
http://www.fusionauthority.com/signup.cfm