I am trying to create my own XML file and break it into separate functions, but I can not do it with cfxml. This example is obviously simplified.
This works great:
<cfcomponent accessors="true">
<cfproperty name="Name" />
<cfproperty name="Model" />
<cfproperty name="Make" />
<cffunction name="BuildCarXML" output="false">
<cfsavecontent variable="xmlCar">
<cfoutput>
<?xml version="1.0" encoding="UTF-8" ?>
<car>
<name>#variables.Name#</name>
#AddMakeElement()#
</car>
</cfoutput>
</cfsavecontent>
<cfreturn xmlCar />
</cffunction>
<cffunction name="AddMakeElement">
<cfsavecontent variable="xmlMake">
<cfoutput>
<make>Something</make>
</cfoutput>
</cfsavecontent>
<cfreturn xmlMake />
</cffunction>
</cfcomponent>
But this creates an XML string with spaces:
<?xml version="1.0" encoding="UTF-8" ?> <car> <name>Ferrari</name> <make>Something</make> </car>
If I use cfxmlor even do XMLParse()cfreturn BuildCarXML, I get the following error:
An error occured while Parsing an XML document.
The processing instruction target matching "[xX][mM][lL]" is not allowed.
Can this be done using cfxml?
source
share