remove HTML encoding convert to RSS

Discussion in 'PHP' started by megler, Mar 2, 2008.

  1. #1
    Seems I'm on a roll tonight. I'm making this a new thread since it's technically a new subject from my last post. I have a script that pulls data from a mysql database and creates a RSS feed out of it.

    Now I'm at the next part of the puzzle - I need to strip out the HTML encoding and replace it with valid xml. (ie. " > < etc)

    I don't care if it's added to my existing script when it pulls the data from the mysql table or if it's a seperate script that I use before inserting the data into the table to begin with. -- make sense?

    I've googled the crap out of this and just don't see an easy solution. Is this actually hard or am I just not finding what I want?

    for reference, here's the script I'm using now in case it can be added to this script vs being a stand alone...

    <?php   
    include('../rss/classes/mysql_connect.php');   
    header('Content-type: application/rss+xml; charset=utf-8');   
    echo "<?xml version=\"1.0\" ?>";   
    echo "   
    <rss version=\"2.0\">   
    <channel>   
    <title>Cute Puppies!</title>   
    <description>Great Pictures and Videos of Cute Puppies!</description>   
    <link>http://mydomain/cute_puppies/</link>   
    " ;   
    $sql = "select * from webref_rss_items";
    $LINK = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD);
    $rs = mysql_query($sql, $LINK);   
    while($row=mysql_fetch_array($rs)) {   
    echo "<item>\n";   
    echo "<title>".$row['title']."</title>\n";   
    echo "<link>".$row['link']."</link>\n"; 
    echo "<description>".$row['description']."</description>\n";   
    echo "</item>\n";   
    }   
    echo " </channel> </rss> " ;   
    ?>
    PHP:
    thanks to anyone that can lend a link, a script or some guidance. As a sidenote, I can't program for crap, I can really only edit existing stuff. :rolleyes:

    Marceia
     
    megler, Mar 2, 2008 IP
  2. able

    able Peon

    Messages:
    44
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Run $row['title'] through htmlentities() e.g. $row['title'] = htmlentities($row['title'])
     
    able, Mar 2, 2008 IP
    megler likes this.
  3. megler

    megler Peon

    Messages:
    68
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks, Able! God, I searched everywhere for THAT? What a "duh" moment! Worked like a charm.

    you gave me an easy fix that does exactly what I need. thanks again!!
     
    megler, Mar 2, 2008 IP