I have made a simple routine in which I build an xml string (no schema or validation).
After building the string I export it to the user using the echo function.
In my header I have the following:
<?php session_start(); ?>
<?php header("Content-Type: text/html; charset=utf-8");?>
<?php header("Content-Disposition:attachment; filename=veldcollection.xml");?>
and in the end I just do this:
echo $_xml;
This will export an xml file called veldcollection.xml.
The problem is, it will add an extra space at the beginning of the exported file, a space that is not at the beginning of the string.
Due to the space, the XML parser won't accept the xml file and will throw an error.
Removing the space manually after the file has been exported will make the file valid.
Can anyone tell me why this space is added and more importantly, how to get rid of it?
Thank you all in advance.
Weedz (Edward W.F. Veld)
After building the string I export it to the user using the echo function.
In my header I have the following:
<?php session_start(); ?>
<?php header("Content-Type: text/html; charset=utf-8");?>
<?php header("Content-Disposition:attachment; filename=veldcollection.xml");?>
and in the end I just do this:
echo $_xml;
This will export an xml file called veldcollection.xml.
The problem is, it will add an extra space at the beginning of the exported file, a space that is not at the beginning of the string.
Due to the space, the XML parser won't accept the xml file and will throw an error.
Removing the space manually after the file has been exported will make the file valid.
Can anyone tell me why this space is added and more importantly, how to get rid of it?
Thank you all in advance.
Weedz (Edward W.F. Veld)