如何在xml文档中添加多个表

时间:2016-09-08 19:16:37

标签: xml coldfusion

<cfset BUSOBJ=XmlNew()>
<cfset BUSOBJ.xmlRoot = XmlElemNew(BUSOBJ,"EMPLOYEEDATA")>
<cfset BUSOBJ.EMPLOYEEDATA.XmlChildren[1].NOTICE = XmlElemNew(BUSOBJ,"NOTICE")>
<cfset BUSOBJ.EMPLOYEEDATA.XmlChildren[1].NOTICE.XmlText = "SomeMsg">
<cfset BUSOBJ.EMPLOYEEDATA.XmlChildren[1].NOTICE = XmlElemNew(BUSOBJ,"STARTDATE")>
<cfset BUSOBJ.EMPLOYEEDATA.XmlChildren[1].NOTICE.XmlText = "#startdate#">
<cfset BUSOBJ.EMPLOYEEDATA.XmlChildren[1].NOTICE = XmlElemNew(BUSOBJ,"ENDDATE")>
<cfset BUSOBJ.EMPLOYEEDATA.XmlChildren[1].NOTICE.XmlText = "#enddate#">

<cfset empIndex = 1>
<cfloop query="qEmpData">
    <cfset empIndex ++>
    <cfset BUSOBJ.EMPLOYEEDATA.XmlChildren[empIndex] = XmlElemNew(BUSINESSOBJ,"EMPLOYEE")>
    <cfset BUSINESSOBJ.EMPLOYEEDATA.XmlChildren[empIndex].EMPLOYEE_ID = XmlElemNew(BUSINESSOBJ,"EMPLOYEE_ID")>
    <cfset BUSINESSOBJ.EMPLOYEEDATA.XmlChildren[empIndex].EMPLOYEE_ID.XmlText = "#qEmpData.EMPLOYEE_ID#">
    <cfset BUSINESSOBJ.EMPLOYEEDATA.XmlChildren[empIndex].EMPLOYEE_TYPE = XmlElemNew(BUSINESSOBJ,"EMPLOYEE_TYPE")>
    <cfset BUSINESSOBJ.EMPLOYEEDATA.XmlChildren[empIndex].EMPLOYEE_TYPE.XmlText = "#qEmpData.EMPLOYEE_TYPE#">
    .....blah,blah,blah

现在,我想在这个XML文档中包含另一个表(循环遍历),我无法弄清楚如何。我以为我可以做一些像设置'BUSOBJ.EMPLTYPELOOKUP ...'的事情,但是无法做到这一点。任何帮助将不胜感激。

emplTypes(查询表 - 从qEmpData查询的上表中使用的id) ID 名称

0 个答案:

没有答案