| | |
php + rss
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2006
Posts: 6
Reputation:
Solved Threads: 0
Hiya!
I'm trying to include my blog- hosted at blogger.com - to my website. The blog is in an rss-feed. Blogger includes the tags that I use in the blog as they are, <a>, <br/> and <img> for example. When I try to read the blogs, it outputs the title and the author correctly, but the description that contains those tags doesn't show as it should.
Here's the php
... and xml can be found at http://dirtybirdrexx.blogspot.com/rss.xml
This code outputs this:
Latest blogs:
About Subliminal EP (by the Slowdowns)
The Beginning (by Dirtybird Rexx)
all blogs
About Subliminal EP (by the Slowdowns)
- the Slowdowns
The Beginning (by Dirtybird Rexx)
- Jyri of DBR
When it should output a lot more text before those signatures (the Slowdowns and Jyri of DBR). I think it has something to do with the <br /> -tags just before the signatures. So I need to find the solution how to stop the description from breaking. I've tried the str_replace function before putting $data to the $postdata -array, but it didn't work.
Help, anyone?
- Jyri
I'm trying to include my blog- hosted at blogger.com - to my website. The blog is in an rss-feed. Blogger includes the tags that I use in the blog as they are, <a>, <br/> and <img> for example. When I try to read the blogs, it outputs the title and the author correctly, but the description that contains those tags doesn't show as it should.
Here's the php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dirtybird Rexx v2</title>
</head>
<body>
<div id="container">
<div id="blue">
<p>Latest blogs:<br />
<?php
if(!($xmlparser = xml_parser_create())){
die("Cannot create parser");
}
$postcount = 0;
$current = "";
function start_tag($parser, $name, $attribs){
global $current;
$current = $name;
global $postcount;
global $postdata;
}
function end_tag($parser, $name){
global $postcount;
if($name=="ITEM"){
$postcount ++;
}
global $postdata;
}
function tag_contents($parser, $data){
global $current;
global $postcount;
global $postdata;
$data = str_replace("ä", "ä", $data);
$data = str_replace("Ä", "Ä", $data);
$data = str_replace("ö", "ö", $data);
$data = str_replace("Ö", "Ö", $data);
if($current == "TITLE"){
$postdata[$postcount]["title"] = $data;
}
if($current == "AUTHOR"){
$postdata[$postcount]["author"] = $data;
}
if($current == "DESCRIPTION"){
$postdata[$postcount]["description"] = $data;
}
}
xml_set_element_handler($xmlparser, "start_tag", "end_tag");
xml_set_character_data_handler($xmlparser, "tag_contents");
$filename = "http://dirtybirdrexx.blogspot.com/rss.xml";
if (!($fp = fopen($filename, "r"))){
die("cannot open ".$filename);
}
while ($data = fread($fp, 8192)){
$data = eregi_replace(">"."[[:space:]]+"."< ",">< ",$data);
if (!xml_parse($xmlparser, $data, feof($fp))) {
$reason = xml_error_string(xml_get_error_code($xmlparser));
$reason .= xml_get_current_line_number($xmlparser);
die($reason);
}
}
xml_parser_free($xmlparser);
for ($i=0;$i<$postcount; $i++){
echo "<br /><strong>".$postdata[$i]["title"]."</strong> (by ".($postdata[$i]["author"]).")";
}
?>
</p>
</div>
<div id="grey">
<h2>all blogs</h2>
<?php
for ($i=0;$i<$postcount; $i++){
echo "<h2>".$postdata[$i]["title"]."</strong> (by ".($postdata[$i]["author"]).")</h2>";
echo "<p>".$postdata[$i]["description"]."</p>";
}
?>
</div>
</div>
</body>
</html>
... and xml can be found at http://dirtybirdrexx.blogspot.com/rss.xml
This code outputs this:
Latest blogs:
About Subliminal EP (by the Slowdowns)
The Beginning (by Dirtybird Rexx)
all blogs
About Subliminal EP (by the Slowdowns)
- the Slowdowns
The Beginning (by Dirtybird Rexx)
- Jyri of DBR
When it should output a lot more text before those signatures (the Slowdowns and Jyri of DBR). I think it has something to do with the <br /> -tags just before the signatures. So I need to find the solution how to stop the description from breaking. I've tried the str_replace function before putting $data to the $postdata -array, but it didn't work.
Help, anyone?
- Jyri
![]() |
Similar Threads
- RSS Feeds (DaniWeb Community Feedback)
- Help With a PHP RSS Parser (PHP)
- php loading (PHP)
- Calling Different Iframes in Page (JavaScript / DHTML / AJAX)
- RSS Generator for vBulletin 3.5.3? (Geeks' Lounge)
- Rss Feeds! (RSS, Web Services and SOAP)
Other Threads in the PHP Forum
- Previous Thread: PHP + WebDAV
- Next Thread: append content of 1 table to another
| Thread Tools | Search this Thread |
301 access apache api array autocomplete beginner binary broken button cakephp checkbox class cms code compression cron curl data database date display dropdown dropdownlist duplicates dynamic echo email error execution file files folder form forms function functions google href htaccess html htmlspecialchars httppost image include insert integration ip javascript joomla jquery limit link links login mail md5 menu methods mlm multiple mysql oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote script search secure server session sessions sms source space sql subscription syntax system table tutorial update upload url validator variable video virus volume votedown web youtube





