| Contents > Developing ColdFusion MX Applications > Using XML and WDDX > Modifying a ColdFusion XML object > Using XML and ColdFusion queries Converting a query object to XML |
|
|
|
|
||
The following example shows how to convert a query object to XML. It uses cfquery to get a list of employees from the CompanyInfo database and saves the information as an XML document.
<!--- Query the database and get the names in the employee table --->
<cfquery name="myQuery" datasource="CompanyInfo">
SELECT FirstName, LastName
FROM employee
</cfquery>
<!--- Create an XML document object containing the data --->
<cfxml variable="mydoc">
<employee>
<cfoutput query="myQuery">
<name>
<first>#FirstName#</first>
<last>#LastName#</last>
</name>
</cfoutput>
</employee>
</cfxml>
<!--- dump the resulting XML document object --->
<cfdump var=#mydoc#>
<!--- Write the XML to a file --->
<cffile action="write" file="C:\inetpub\wwwroot\xml\employee.xml"
output=#toString(mydoc)#>
|
|
||
| Contents > Developing ColdFusion MX Applications > Using XML and WDDX > Modifying a ColdFusion XML object > Using XML and ColdFusion queries Converting a query object to XML |
|
|
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6.1
Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.