文章作者 : weblu [ weblu@21cn.com ] Web URL : http://
上载日期 : 2000-12-25
<!--- 指定xml文件存放的目录 --->
<cfset xml_path="D:\Inetpub\wwwroot\xml\">
<!--- 查询Table中符合条件Condition的数据 --->
<cfquery name="GetData" datasource="#application.Datasource#" password="#application.DataBasePassword#" username="#application.DataBaseUser#" dbtype="#application.dbType#">
select * from Table where Condition
</cfquery>
<!--- 用CFWDDX把查询得到的数据转换成xml格式 --->
<CFWDDX ACTION='cfml2wddx' input=#GetData# output='xml_Data'>
<!--- 输出xml文件 --->
<cffile action="WRITE" file="#xml_path#DataFile.xml" output="#xml_Data#" addnewline="Yes">
<!--- 读取xml文件 --->
<cffile action="READ" file="#xml_path#DataFile.xml" variable="xml_Data">
<!--- 把读取的xml数据转换为一个查询 --->
<CFWDDX ACTION='wddx2cfml' input=#xml_Data# output='xml_Query'>
<!--- 输出查询 --->
<cfoutput query="xml_Query">
......
</cfoutput>
应用:在后台生成xml文件,在前台调用,使前台页面不直接访问数据库,减轻数据库的负担。
|