Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / March 2006



Tip: Looking for answers? Try searching our database.

CFC not returning XML

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rottmanja - 31 Mar 2006 00:30 GMT
I am writing a function with in my cfc that I am using to return xml. The test
code outisde of my function works perfectly, however when I put the code with
in my function the I get this error.

XML Parsing Error: xml declaration not at start of external entity
Location: http://flex.homesmartagent.com/test.cfm
Line Number 3, Column 1:<?xml version="1.0" encoding="utf-16"?>
^

This is my function code:

    <cffunction name="displayDocsListQry" access="remote" returntype="xml"
output="false">
        <cfargument name="fileNum" required="no" type="string" />
            <cfdirectory action="list" recurse="yes"
directory="#APPLICATION.storePath##APPLICATION.systemInfo.fld_officeCode#/#argum
ents.fileNum#" name="ListDir" />
                <cfquery name="DirQry" dbtype="query">
                select * from ListDir
                where Type = 'Dir'
                </cfquery>
                <cfprocessingdirective suppresswhitespace="Yes">
                <cfcontent type="text/xml; charset=utf-16">
                <cfxml variable="xmlobject">
                <cfoutput>
                        <fileNum label="L060001">
                            <cfloop query="DirQry">
                                <directory label="#DirQry.name#">
                                <cfquery name="fileQry" dbtype="query">
                                select * from ListDir
                                where Type = 'File' and directory =
'#APPLICATION.storePath##APPLICATION.systemInfo.fld_officeCode#/#arguments.fileN
um#/#DirQry.name#'
                                </cfquery>
                                        <cfloop query="fileQry">
                                        <document label="#fileQry.name#" />
                                        </cfloop>
                                </directory>
                            </cfloop>
                        </fileNum>
                </cfoutput>
                </cfxml>
                <cfset myvar=toString(xmlobject)>
                <cfset mynewvar=replace(myvar, "UTF-8", "utf-16")>
            </cfprocessingdirective>
            <cfreturn mynewvar />
    </cffunction>
Not Nick - 31 Mar 2006 03:22 GMT
You problem seem to be that you have whitespcae in front of the declaration
(<?xml version="1.0" encoding="utf-16"?>) and that is not allowed. Use cfsilent
or cfsetting enablecfoutputonly="true" to make sure that no whitespaces or
linefeeds sneeks by before you function returns your XML
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.