updating existing xml doc
i have an xml doc that looks like this
<?xml version="1.0" encoding="UTF-8"?>
<messageList>
<message>
<sender>john</sender>
<forPage>home</forPage>
</message>
</messagelist>
i want to add another element called <forPage> under the current one.(one to many relationship). my code below overwrite the first entered <forPage>
<cfset arrayInsertAt(xApps.messageList.xmlChildren,1,xmlElemNew(xApps,'message'))>
<cfset xApps.messageList.message[1].sender = xmlElemNew(xApps,'sender')>
<cfset xApps.messageList.message[1].sender.xmlText = "john">
<cfset xApps.messageList.message[1].forPage = xmlElemNew(xApps,'forPage')>
<cfset xApps.messageList.message[1].forPage.xmlText = "home">
<cfset xApps.messageList.message[1].forPage = xmlElemNew(xApps,'forPage')>
<cfset xApps.messageList.message[1].forPage.xmlText= "sales">
i am looking to update my xml like this
<?xml version="1.0" encoding="UTF-8"?>
<messageList>
<message>
<sender>john</sender>
<forPage>home</forPage>
<forPage>sale</forPage>
</message>
</messagelist>
this code will eventually be put into a loop to account for numerous occurrences of <forpage>.
thanks for your time
