Skip to main content
Participating Frequently
July 15, 2009
Question

White space in XML source code

  • July 15, 2009
  • 3 replies
  • 683 views

Ok, I have tried all of the tricks to prevent white space in the code.  The page displays fine, but there are 4 lines at the top of the source code making the file not vaild.  Ideas?  Thanks in advance.

    This topic has been closed for replies.

    3 replies

    Dileep_NR
    Inspiring
    July 16, 2009

    Plz give your code sett and also try this

    use  <cfsetting enablecfoutputonly="true"> at the top of the page

    Inspiring
    July 15, 2009

    You can use the reset attribute of CFCONTENT to clear any output, such as whitespace, that occurs before the CFCONTENT tag.  See quick sample below.  If this doesn't work for you can you post your code?

    <cfsavecontent variable="sampleXml"><?xml version="1.0"?> <!--- no line break or other space between opening cfsavecontent and xml declaration --->
        <people>
            <name>Jon Smith</name>
            <name>Rose Tyler</name>
        </people>
    </cfsavecontent>

    <!--- use reset attribute of cfcontent to clear output above cfcontent tag, do not include any whitespace between close of cfcontent and start of output --->
    <cfcontent type="text/xml" reset="yes" /><cfoutput>#sampleXml#</cfoutput>

    ilssac
    Inspiring
    July 15, 2009

    What tricks have you tried?

    Did you apply these tricks to all the files that might be involvoed in generating the XML file?  Don't forget any Application.cfm|Applicaiton.cfc file that may apply.