Jster
03-20-2007, 09:35 AM
I'm testing to creating an xml file using php and i am running into an issue. It keeps putting a space in front of the string so it gives me an error "xml declaration not at start of external entity". any ideas as to why a space is being placed in the beginning of the string. Here is the code I am using.
<?php
header("Content-type: text/xml");
$xml_output="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$xml_output .= "<entries>\n";
for($counter = 0; $counter <10; $counter++)
{
$xml_output .= "\t<entry>\n";
$xml_output .= "\t\t<date>03/20/20" . $counter . "</date>\n";
$xml_output .= "\t\t<text>Some Text HERE " . $counter . "</text>\n";
$xml_output .= "\t</entry>\n";
}
$xml_output .= "</entries>";
echo $xml_output;
?>
<?php
header("Content-type: text/xml");
$xml_output="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$xml_output .= "<entries>\n";
for($counter = 0; $counter <10; $counter++)
{
$xml_output .= "\t<entry>\n";
$xml_output .= "\t\t<date>03/20/20" . $counter . "</date>\n";
$xml_output .= "\t\t<text>Some Text HERE " . $counter . "</text>\n";
$xml_output .= "\t</entry>\n";
}
$xml_output .= "</entries>";
echo $xml_output;
?>