Welcome Guest, Not a member yet? Register   Sign In
Extra semicolon (RSS Feed)
#1

[eluser]xmonader[/eluser]
Hi, I'm trying to build some RSS Feed http://www.derekallard.com/blog/post/bui...e-igniter/
rss.php

Code:
<?php echo '<?xml version="1.0" encoding="UTF-8"?>'?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
    &lt;title&gt;&lt;?php echo $feed_name; ?&gt;&lt;/title&gt;
    &lt;link&gt;&lt;?php echo $feed_url; ?&gt;&lt;/link&gt;
    <description>&lt;?php echo $page_description; ?&gt;</description>
    <dc:language>&lt;?php echo $page_language; ?&gt;</dc:language>
    <dc:creator>&lt;?php echo $creator_email; ?&gt;</dc:creator>
    <dc:rights>Copyright &lt;?php echo gmdate("Y", time()); ?&gt;</dc:rights>
    <admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
    &lt;?php foreach($posts->result() as $entry): ?&gt;
        <item>
          &lt;title&gt;&lt;?php echo xml_convert($entry->topic_title); ?&gt;&lt;/title&gt;
          &lt;link&gt;&lt;?php echo site_url('main/topic_view/'. $entry->topic_id) ?&gt;&lt;/link&gt;
          <guid>&lt;?php echo site_url('main/topic_view/'. $entry->topic_id) ?&gt;</guid>
          <description>&lt;![CDATA[
      &lt;?= str_replace('/img/post_resources/', base_url() . 'img/post_resources/', $entry->post_text); ?&gt;
      ]]></description>
      <pubDate>&lt;?php echo date ('r', mysql_to_unix($entry->topic_start_time));?&gt;</pubDate>
        </item>
    &lt;?php endforeach; ?&gt;
    </channel>
</rss>
after calling the controller i get
Code:
&lt;?xml version="1.0" encoding="UTF-8"; ?&gt;
...
REST OF RSS
I don't know what appends that semicolon?
#2

[eluser]pickupman[/eluser]
I don't know if it's a typo on the board but shouldn't the first line be changed from:
Code:
&lt;?php echo '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'?&gt;

// Change to
&lt;?php echo '&lt;?xml version="1.0" encoding="UTF-8"?&gt;'; ?&gt;
#3

[eluser]xmonader[/eluser]
pickupman: Yes the first line is
Code:
&lt;?php echo '&lt;?xml version="1.0" encoding="UTF-8"?&gt;';?&gt;

Even if i replace it with
Code:
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
It gets transformed to
Code:
&lt;?xml version="1.0" encoding="UTF-8"; ?&gt;
Sad
#4

[eluser]xmonader[/eluser]
Got it fixed --short tags problem
here's the simple way
Code:
&lt;?= '<' . '?xml version="1.0" encoding="utf-8"?' . '>' ?&gt;
Thanks Smile
#5

[eluser]xmonader[/eluser]
After checking a few applications updated to CI 2 I found that all feeds are broken! and none of the snippets above are working.
The only working thing is
Code:
//FIX ME.
        echo header("Content-Type: application/rss+xml".'?xml version="1.0" encoding="utf-8"?' . '>');
        
        $this->load->view('rss', $data);
#6

[eluser]pickupman[/eluser]
You don't echo the header(). I put this as the first line of the controller's method:
Code:
header("Content-Type: application/rss+xml");

Here his the first line of my view:
Code:
&lt;?php
echo '&lt;?xml version="1.0" encoding="utf-8"?&gt;' . "\n";
?&gt;
#7

[eluser]xmonader[/eluser]
Thanks, but still doesn't work
Code:
function index() {
        //FIX ME.
        header("Content-Type: application/rss+xml");
        
        $data['encoding'] = 'utf-8';
        $data['feed_name'] =  $this->Cikimeta_model->getMetaValue("wiki", "wiki_title");
        $data['feed_url'] = base_url();
        $data['page_description'] = 'SOME DESCRIPTION';
        $data['page_language'] = 'en-ca';
        $data['creator_email'] = 'Ahmed Youssef is at xmonader[at]gmail[dot]com';
        $data['posts'] = $this->Pages_model->getLatestPages(10);

        $this->load->view('rss', $data);
    }

the RSS view
Code:
&lt;?php
echo '&lt;?xml version="1.0" encoding="utf-8"?&gt;' . "\n";
?&gt;  
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
    &lt;title&gt;&lt;?php echo $feed_name; ?&gt;&lt;/title&gt;
    &lt;link&gt;&lt;?php echo $feed_url; ?&gt;&lt;/link&gt;
    <description>&lt;?php echo $page_description; ?&gt;</description>
    <dc:language>&lt;?php echo $page_language; ?&gt;</dc:language>
    <dc:creator>&lt;?php echo $creator_email; ?&gt;</dc:creator>
    <dc:rights>Copyright &lt;?php echo gmdate("Y", time()); ?&gt;</dc:rights>
    <admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
    &lt;?php foreach($posts->result() as $entry): ?&gt;
        <item>
          &lt;title&gt;&lt;?php echo xml_convert($entry->page_title); ?&gt;&lt;/title&gt;
          &lt;link&gt;&lt;?php echo site_url('pages/'. $entry->page_id) ?&gt;&lt;/link&gt;
          <guid>&lt;?php echo site_url('topic/view_topic/'. $entry->page_id) ?&gt;</guid>
          <description>&lt;![CDATA[
      &lt;?= str_replace('/img/post_resources/', base_url() . 'img/post_resources/', word_limiter($entry->pagecontent, 25)) ?&gt;
      ]]></description>
      <pubDate>&lt;?php echo date ('r', mysql_to_unix($entry->createdat));?&gt;</pubDate>
        </item>
    &lt;?php endforeach; ?&gt;
    </channel>
</rss>

Hmmm..?
#8

[eluser]InsiteFX[/eluser]
You still have a short tag here!
Code:
&lt;?= str_replace('/img/post_resources/', base_url()

InsiteFX
#9

[eluser]xmonader[/eluser]
still not working :S

Code:
&lt;?xml version="1.0" encoding="utf-8"; ?&gt;
adding that semi colon is driving me crazy Angry
#10

[eluser]pickupman[/eluser]
Just out of curiosity, do you have rewrite short tags set to true at the near bottom of your application/config.php file?

What happens when you try again:
Code:
&lt;?php echo '&lt;?xml version="1.0" encoding="utf-8"?' . '?&gt;' . "\n"; ?&gt;

//or maybe
&lt;?php echo str_replace(';','','&lt;?xml version="1.0" encoding="utf-8"?' . '?&gt;'). "\n"; ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB