Hi... new here.

Newbie to ColdFusion, trying to generate XML.  I was able to create a
simple XML file from a database table, but am not sure how to create
child nodes WITHIN child nodes.  Currently, I have:

<cfscript>
        lrXML = XmlNew();
        lrXML.xmlRoot = XmlElemNew(lrXML,"lData");
for (i = 1; i LTE #qAllLessons.RecordCount#; i = i + 1){
                lrXML.lData.XmlChildren[i] = XmlElemNew(lrXML,"Lesson");
                lrXML.lData.XmlChildren[i].XmlText = #qLessons.Lesson#;
}
</cfscript>

That works, but how do I create a child node within the "Lesson" node?
OR, is there a cfscript out there that will take a table and convert its
contents to XML with the nodes being named what the field names are
named?  I have searched the web, but haven't found one yet.

So far, I have tried:

<cfscript>
        lrXML = XmlNew();
        lrXML.xmlRoot = XmlElemNew(lrXML,"lData");
        for (i = 1; i LTE #qAllLessons.RecordCount#; i = i + 1){
                lrXML.lData.XmlChildren[i] = XmlElemNew(lrXML,"Lesson");
                lrXML.lData.XmlChildren[i].XmlChildren[i] =
XmlElemNew(lrXML,"Content");
                lrXML.lData.XmlChildren[i].XmlChildren[i].XmlText =
"Hello " & #qAllLessons.RecordCount#;
        }
</cfscript>

And also:

<cfscript>
        lrXML = XmlNew();
        lrXML.xmlRoot = XmlElemNew(lrXML,"lData");
        for (i = 1; i LTE #qAllLessons.RecordCount#; i = i + 1){
                lrXML.lData.XmlChildren[i] = XmlElemNew(lrXML,"Lesson");
                lrXML.lData.XmlChildren[i].XmlChildren[i] =
XmlElemNew(lrXML,"Content");
                lrXML.lData.XmlChildren[i].Lesson.XmlText = "Hello " &
#qAllLessons.RecordCount#;
        }
</cfscript>

But no luck. Ideas?



Jason Merrill   |   E-Learning Solutions   |  icfconsulting.com











NOTICE:
This message is for the designated recipient only and may contain privileged or 
confidential information. If you have received it in error, please notify the 
sender immediately and delete the original. Any other use of this e-mail by you 
is prohibited.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get help! RoboHelp
http://www.houseoffusion.com/banners/view.cfm?bannerid=58

Message: http://www.houseoffusion.com/lists.cfm/link=i:15:1295
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/15
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:15
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to