SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast aaron888's Avatar
    Join Date
    Apr 2009
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    My RSS feed ... the text formatting lost.. (screenshot attached)

    Hello Sitepoint Lovely People,

    I just started learning how to make a RSS feed.
    Although I have successfully made 1, but the words are ALL OVER THE PLACE
    ------------------------------------------------------------
    SCREENSHOT


    ------------------------------------------------------------
    Usually, I use the <pre></pre> html tags to ensure it displays properly in my normal webpage.

    but now that it is in XML, ..... how do I make all the formatting back to normal ?

    My rss.php file looks is as below
    PHP Code:
    <? header('Content-type: text/xml'); ?>

    <rss version="2.0">
    <channel>
    <title>Subscription</title>
    <description>Profile</description>
    <link>http://mysite.com/</link>

    <?
    $con 
    mysql_connect("localhost","abc","123");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("MYdb"$con);

    $result mysql_query("SELECT * FROM joke WHERE username = '" $_GET['username'] . "' ORDER BY `id` DESC LIMIT 0, 5 ");

    while(
    $row mysql_fetch_array($result)){

    ?>
          <item>
            <title> <?=htmlentities(strip_tags($row['title1'])); ?></title>
            <description><?=htmlentities(strip_tags($row['main1'],'ENT_QUOTES'));?></description>
            <link>http://mysite.com/joke2.php?id=<?php echo $row['id'];?></link>
    </item>
    <? ?>
    </channel>
    </rss>
    Thanks for the advice.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,043
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    Characters that you don't want to be parsed should go inside CDATA eg.
    Code XML:
    <description><![CDATA[<p>Paragraph <em>one</em></p>]]></description>

  3. #3
    SitePoint Enthusiast aaron888's Avatar
    Join Date
    Apr 2009
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wooohoooo thank you Mittineague. The CDATA thing has SOLVED my problem.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •