Thanks Dave.
So basically I am not doing anything inherently wrong, correct?

When you say 'easier just to get rid of
> whitespace at design time if I care about it, '
what do you mean by that? Design time as in when it arrives on the FMS  
side?

I'll also take your advice and try to put my cfoutput tags on a diet!

Cheers

Stefan







On 24 Mar 2009, at 13:12, Dave Watts wrote:

>
>> I'm building a web based API to my database. I POST some data from
>> Flex (or FMS), I get back XML. That works pretty well (but note I am
>> not a CF programmer by trade...).
>>
>> What I'm struggling with is suppressing all the whitespace in the  
>> XML.
>> My CFM page essentially looks like this (simplified):
>>
>> <cfsetting enablecfoutputonly="yes">
>> <cfprocessingdirective pageencoding = "utf-8" suppressWhiteSpace =
>> "Yes">
>>
>> <cfxml variable="userXML">
>>        <cfoutput><result action="none" status="error"></cfoutput>
>>        <cfoutput><message>no action defined</message></cfoutput>
>>        <cfoutput></result></cfoutput>
>> </cfxml>
>>
>> <cfoutput>#toString(userXML)#</cfoutput>
>> </cfprocessingdirective>
>>
>> If I hit this from FMS and trace the response I see this:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <result action="none" status="error"><message>no action defined</
>> message></result>
>>
>> It has a big fat empty line between the first and second line of
>> content (I assume the first line is added on the fly by CF by me
>> setting the page encoding).
>>
>> I'm wondering what suppressWhiteSpace = "Yes" actually does because
>> intially I did not wrap each line of my output in cfoutput tags, but
>> that resulted in all the tab intends to be outputted as well.
>>
>> Are there any best practices on how to format XML responses in CF?
>
> In your example code, you don't need any of the CFOUTPUT tags except
> the last one. CFXML lets you build an XML document object in memory.
>
> That said, I don't know if that'll affect your whitespace output. In
> my experience, I usually find it's easier just to get rid of
> whitespace at design time if I care about it, which I might in the
> case of XML.
>
>> And one more question: what exactly is returned to me if I omit the
>> toString conversion on the last line (toString(userXML)) ? My FMS
>> trace shows
>> coldfusion.xml.xmlnodel...@140e0f2
>> and I have no clue how I could then process that, which is why I  
>> ended
>> up with toString (note FMS uses ActionScript 1 so I do not have the
>> luxuries of E4X and the like for parsing, instead FMS is very picky
>> when it comes to XML formatting).
>
> FMS uses ActionScript 1 still? Yikes!
>
> Anyway, CFXML creates an XML document object in memory. You can't just
> output one of those as a string; when you do, you get the funky syntax
> you saw. That is basically telling you that there's an object of type
> coldfusion.xml.XmlNodeList at a certain location in memory.
>
> Dave Watts, CTO, Fig Leaf Software
> http://www.figleaf.com/
>
> Fig Leaf Software provides the highest caliber vendor-authorized
> instruction at our training centers in Washington DC, Atlanta,
> Chicago, Baltimore, Northern Virginia, or on-site at your location.
> Visit http://training.figleaf.com/ for more
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5833
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.37

Reply via email to