Unqualified XML's and cfheader
I've been playing around with creating an XML file this morning from a plain .cfm page and came across an annoyance. Now I've done this loads but this morning I was creating my own Ajax functions which meant the cfm page had to return a fully qualfied as XML which was passed into Javascripts XML parser, but Js was passing an error. The test code was simple
[xml.cfm]
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<cfheader name="Content-Type" value="text/xml">
<?xml version="1.0" encoding="UTF-8"?>
<root>
<node>
<child>1</child>
</node>
<root>
1<cfheader name="Content-Type" value="text/xml">
2<?xml version="1.0" encoding="UTF-8"?>
3<root>
4 <node>
5 <child>1</child>
6 </node>
7<root>
The problem was CFHEADER adds a couple of blank lines to the top of the page meaning that the page did not pass as XML. Well thanks to Rob Wilkerson on CF-Talk the anser was obvious simple - use CFCONTENT
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
<cfcontent type="text/xml" reset="Yes" />
<?xml version="1.0" encoding="UTF-8"?>
<root>
<node>
<child>1</child>
</node>
<root>
1<cfcontent type="text/xml" reset="Yes" />
2<?xml version="1.0" encoding="UTF-8"?>
3<root>
4 <node>
5 <child>1</child>
6 </node>
7<root>
I did try a few other ways of surpressing the white space usin a variety of methods but nothing came close.