NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Php & RSS

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Reply
 
LinkBack Thread Tools
Old 06-14-2009, 01:23 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
freeflow's Avatar
Join Date: Dec 2006
Posts: 236
freeflow is on a distinguished road
 



Help! Php & RSS


Hi everyone. I once again need some help programing. What
I would like to do is add the following link in the beginning of the
“Read the Rest of This Story” link.

This is the link to insert:
www.google.de/gwt/n?u=

This is what I would like the source code to look like, is it possible?

Quote:
</b>
<div class="text">PC World - PC World editors Tim Moynihan and Robert Strohmeyer sit down with Macworld editorial director Jason Snell for a breakdown of all this week's Apple news from WWDC. In the mix: What to expect from the iPhone 3G S, long-awaited features on the new MacBook Pro laptops, and how Snow Leopard will improve the Mac experience. Yes, it's all Apple stuff this week, and our editors don't pull their punches.
<br /><a href="http://www.google.de/gwt/n?u=us.rd.yahoo.com/dailynews/rss/cellphones/*iPhone 3G S, New MacBook Pros, and Snow Leopard on PC World Podcast 33 by PC World: Yahoo! Tech
" target="_blank">Read the Rest of This Story</a></div><br />
<b>Even PCers Like Apple's Safari as Downloads Top 11M
(NewsFactor)

</b>
PHP Code:
<?
  $var 
= @$_GET['z'] ;
  
$var2 = @$_GET['q'] ;
  
echo 
"<h4> Yahoo!  News - $var2</h4>";


$feed_url "http://$var"// change to the feed you wish to use!

class RSSParser {

   var 
$insideitem false;
   var 
$tag "";
   var 
$title "";
   var 
$description "";
   var 
$link "";

   function 
startElement($parser$tagName$attrs) {
       if (
$this->insideitem) {
           
$this->tag $tagName;
       } elseif (
$tagName == "ITEM") {
????: NamePros.com http://www.namepros.com/programming/589986-php-and-rss.html
           
$this->insideitem true;
       }
   }

   function 
endElement($parser$tagName) {
       if (
$tagName == "ITEM") {

           
           print 
"
           <b>" 
$this->title "</b>
           <div class=\"text\">" 
$this->description "<br /><a href=\"" $this->link "\" target=\"_blank\">Read the Rest of This Story</a></div><br />";
????: NamePros.com http://www.namepros.com/showthread.php?t=589986
            
           
$this->title "";
           
$this->description "";
           
$this->link "";
           
$this->insideitem false;
           

       }
   }

   function 
characterData($parser$data) {
       if (
$this->insideitem) {
           switch (
$this->tag) {
               case 
"TITLE":
               
$this->title .= $data;
               break;
               case 
"DESCRIPTION":
               
$this->description .= $data;
               break;
               case 
"LINK":
               
$this->link .= $data;
               break;
           }
       }
   }
}
    
    
$xml_parser xml_parser_create();
    
$rss_parser = new RSSParser();
    
xml_set_object($xml_parser,&$rss_parser);
    
xml_set_element_handler($xml_parser"startElement""endElement");
    
xml_set_character_data_handler($xml_parser"characterData");
    
$fp fopen("$feed_url","r")
       or die(
"Error reading RSS data.");
    while (
$data fread($fp4096))
       
xml_parse($xml_parser$datafeof($fp))
           or die(
sprintf("XML error: %s at line %d",  
               
xml_error_string(xml_get_error_code($xml_parser)),  
               
xml_get_current_line_number($xml_parser)));
    
fclose($fp); 
    
    
xml_parser_free($xml_parser);
    

?>
freeflow is offline   Reply With Quote
Old 06-14-2009, 11:27 PM   #2 (permalink)
I'll do it
 
-Nick-'s Avatar
Join Date: Dec 2005
Location: India
Posts: 6,927
-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness
 


Member of the Month
September 2007
Adoption
Yes it is possible.

You might have to change the template file where it says MORE in wordpress [Assuming this is wordpress related]
-Nick- is offline   Reply With Quote
Old 06-16-2009, 11:31 AM THREAD STARTER               #3 (permalink)
NamePros Regular
 
freeflow's Avatar
Join Date: Dec 2006
Posts: 236
freeflow is on a distinguished road
 



No I am not using Wordpress, just XHTML & PHP. Isn't There a way to place the link [PHP]www.google.de/gwt/n?u=[PHP] within the print after the <a href=\"" . ? But I don't think this will work because if I understand this code correctly the "&this" variable is [PHP]http://www.google.de/gwt/n?u=us.rd.yahoo.com/dailynews/rss/cellphones....?[PHP]
????: NamePros.com http://www.namepros.com/showthread.php?t=589986

PHP Code:
unction endElement($parser$tagName) { 
????: NamePros.com http://www.namepros.com/showthread.php?t=589986
       if (
$tagName == "ITEM") { 

            
           print 

           <b>" 
$this->title "</b> 
           <div class=\"text\">" 
$this->description "<br /><a href=\"" $this->link "\" target=\"_blank\">Read the Rest of This Story</a></div><br />"
             
           
$this->title ""
           
$this->description ""
           
$this->link ""
           
$this->insideitem false
freeflow is offline   Reply With Quote
Old 06-16-2009, 09:15 PM   #4 (permalink)
I'll do it
 
-Nick-'s Avatar
Join Date: Dec 2005
Location: India
Posts: 6,927
-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness-Nick- Has achieved greatness
 


Member of the Month
September 2007
Adoption
PHP Code:
unction endElement($parser$tagName) { 
       if (
$tagName == "ITEM") { 

$link $this->link;
$link substr($link11); 
$link "www.google.de/gwt/n?u=" $link;
           print 

           <b>" 
$this->title "</b> 
           <div class=\"text\">" 
$this->description "<br /><a href=\"" $link "\" target=\"_blank\">Read the Rest of This Story</a></div><br />"
????: NamePros.com http://www.namepros.com/showthread.php?t=589986
             
           
$this->title ""
           
$this->description ""
????: NamePros.com http://www.namepros.com/showthread.php?t=589986
           
$this->link ""
           
$this->insideitem false
This will do you will have to remove h t t p : / / w w w .

From that Yahoo RSS URL's and append the Error in front of it before printing each element.
-Nick- is offline   Reply With Quote
Old 06-16-2009, 10:00 PM THREAD STARTER               #5 (permalink)
NamePros Regular
 
freeflow's Avatar
Join Date: Dec 2006
Posts: 236
freeflow is on a distinguished road
 



Thanks
freeflow is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
RSS Traffic! Feed your RSS to Many sites in seconds! RSS Traffic Detonator. lazyleo For Sale / Advertising Board 1 05-19-2007 04:23 AM
83 scripts for sell cesarian Scripts For Sale 3 02-16-2007 08:00 AM
Anyone know a php script that convert rss to text file? cesarian Programming 1 08-18-2006 02:45 PM
Submit your articles and news releases easy to RSS feed services Hostnetric Content For Sale 4 12-24-2005 08:45 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 11:57 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger