# XML PHP problem

**URL:** <https://forum.kirupa.com/t/xml-php-problem/276870>\
**Category:** programming\
**Created:** [December 4, 2008, 2:54pm UTC](https://forum.kirupa.com/t/xml-php-problem/276870 "2008-12-04T14:54:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aldor](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@Aldor](https://forum.kirupa.com/u/Aldor)\
**Post date:** [December 4, 2008, 2:54pm UTC](https://forum.kirupa.com/t/xml-php-problem/276870/1 "2008-12-04T14:54:04Z")

</div>

Hey dudes,  
I have a problem with making rss feed with php.  
i generate the XML file and when i try to open it in the browser i get the following error:

XML Parsing Error: not well-formed  
Location: [http://localhost/sms-feed.php](http://localhost/sms-feed.php)  
Line Number 1, Column 2:﻿﻿﻿﻿﻿﻿\<?xml version=“1.0” encoding=“UTF-8”?\>  
-^  
and here is the PHP code that generates the XML doc:

```php
require_once "db/MessageQueries.php";
$mq = new MessageQueries();

header("Content-type: text/xml");  
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
";
// Set RSS version.
echo "
<rss version=\"2.0\"> ";

$now = date("D, d M Y H:i:s");

echo "
<channel>

<title>SMS Feed</title>
<description>Customers feedback</description>
<pubDate>$now</pubDate>
<link>http://www.raahe247.net</link>
";

$rss = $mq->getMessages();

for($i =0; $i<count($rss);$i++) {
	$sms = $rss[$i][message];
	$time = $rss[$i][ts_sended];
	echo "<item>
	<title></title>
	<description><![CDATA[$sms]]></description>
	<pubDate>$time</pubDate>
	<link></link>
	</item>";
}

echo "</channel>
</rss>";

```

When i take the source from browser , it seems to be ok. I guess i have messed up with encodes somehow, coz if i chance all my php code files to ANSI the rss feed works fine. I rather use utf-8 because of special characters. I wish u have some ideas what might be wrong. I have tried all kind of stuff with no success.

Aldor
