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]
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
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.
| Tweet |
| If you like what you see on the website and/or this post has helped you out in some way please consider donating to help keep me in beer vodka. The donations are made through Paypal, which accepts almost any credit card or eCheck. |