Unstoppable Domains

Php & RSS

Spaceship Spaceship
Watch

freeflow

Established Member
Impact
13
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?

</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:
<?
  $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") {
           $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 />";
            
           $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($fp, 4096))
       xml_parse($xml_parser, $data, feof($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);
    

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Yes it is possible.

You might have to change the template file where it says MORE in wordpress [Assuming this is wordpress related]
 
0
•••
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]

[PHP]unction 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 />"; 
             
           $this->title = ""; 
           $this->description = ""; 
           $this->link = ""; 
           $this->insideitem = false;
 
0
•••
PHP:
unction endElement($parser, $tagName) { 
       if ($tagName == "ITEM") { 

$link = $this->link;
$link = substr($link, 11); 
$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 />"; 
             
           $this->title = ""; 
           $this->description = ""; 
           $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.
 
1
•••
Thanks :laugh:
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back