It is currently Mon Sep 06, 2010 6:06 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: XML Parsing / RSS Feed
PostPosted: Sat Feb 06, 2010 10:29 am 
New php-forum User
New php-forum User
Joined: Sat Feb 06, 2010 10:24 am
Posts: 1

I am reading from a cached file with XML. I am trying to display a link to a website from the feed.

An example of the link I am trying to use is:
http://c.moreover.com/click/here.pl?j25 ... &w=2390512

What is coming through in my array is:
w=2390512

The code is stripping the first portion of the URL to the ampersand sign. I have tried to use urlencode and urldecode but it does not affect it. Any suggestions, what am I doing wrong?

Thanks in advance.

Code:
         $depth = array();
            $content = array();
            $curtag = "";
            $newsbuffer = "";
            $headline_count = 1;

            function startElement($parser, $name, $attrs) {
                global $depth;
                global $curtag;
                global $myattrs;

                $curtag = $name;
                $depth[$parser]++;
                $myattrs=$attrs;
            }

            function endElement($parser, $name) {
                global $depth;
                global $curtag;
                global $content;
                global $newsbuffer;
                global $headline_count;

                $curtag = "";
                $depth[$parser]--;
               
                if (strtoupper($name) == "ARTICLE" && $headline_count < 11) {
                  
                  $newsbuffer .= "<a href='" . $content[0] . "' target='_blank'>" . $content[1] . "</a><br>" . $content[2] . " (" . $content[4] . ") - " . $content[3] . "\n<br>\n<br>\n";               
                  $headline_count++;
                }
            }

            function characterData($parser, $data) {
               global $curtag;
               global $content;
               
               
               switch (strtoupper($curtag)) {
               case "URL":
                  $content[0] = $data;
                  break;
               case "HEADLINE_TEXT":
                  $content[1] = $data;
                  break;
               case "SOURCE":
                  $content[2] = $data;
                  break;
               case "HARVEST_TIME":
                  $content[3] = $data;
                  break;
               case "DOCUMENT_URL";
                  $content[4] = $data;
                  break;   
               }
            }

            if (($fp = @fopen($cachefile, "r"))) {

               $xml_parser = xml_parser_create();
               xml_set_element_handler($xml_parser, "startElement", "endElement");
               xml_set_character_data_handler($xml_parser, "characterData");

               $newsbuffer = "";
               while ($data = fread($fp, filesize($cachefile))) {
                  
                  if (!xml_parse($xml_parser, $data, feof($fp))) {
                     //error
                  }
               }
               xml_parser_free($xml_parser);
               fclose($fp);



Offline
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours


 Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Sponsored by Dreamlink Web hosting and Traduzioni Rumeno Italiano and ASSP Deluxe for cPanel.

 
cron