I have written a script in ColdFusion that grabs all of the HTML content for my website in a database table and creates an XML document object. Below is my code so far.
<!--- Get page info --->
<cfquery name="qPageInfo" datasource="#application.datasource#">
SELECT top 800 id, title, info, app
FROM sitePublic
</cfquery>
<cfdump var="#qPageInfo#">
<!--- Creating XML document object w/ sitePublic data --->
<cfxml variable="xmlPageInfo">
<page>
<cfoutput query="qPageInfo">
<id>#qPageInfo.id#</id>
<pagecontent>#Trim("#XMLFormat(qPageInfo.info)#")#</pagecontent>
</cfoutput>
</page>
</cfxml>
<!---<cfdump var="#xmlPageInfo#">--->
<!--- Need to figure out how to output to a file --->
<cffile action="write" file="%filepath%/webcontent.xml" output="#qPageInfo#">
I was able to successfully do a cfdump on the XML document object and it dumped all content for all web pages in the browser window.
However, the part I cannot seem to get working is the last line, <cffile> to output the XML data to an XML file. Below is the error I get when trying to run execute this.
The expression has requested a variable or an intermediate expression result as a simple value. However, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.
The most likely cause of the error is that you tried to use a complex value as a simple one. For example, you tried to use a query variable in a cfif tag.
I am new to ColdFusion so I could be leaving something out in my code, does anyone have an idea on how to fix this?
#Trim( XMLFormat(qPageInfo.info) )#instead of#Trim("#XMLFormat(qPageInfo.info)#")#. - Leighoutput="#qPageInfo#"beoutput="#xmlPageInfo#"You build the xml but then use the query output to write not the xml. - haxtbh