[php]problem z xml_parser_create

0

Mam taka sytuacje: stworzylem plik z funkcja parsowania xml :

<?php
//define(NEWS_NUMBER, 5);
class item{
   var $id;
   var $title;
   var $link;
   var $desc;
   var $pubDate;
   var $category;

   function item($id) {
      $this->id = $id;
      $this->category = $category;
   }
}

$int=0; 
$items=array();
$if_item=0;
$categories=array();


function tag_start($parser,$attr,$params) {
   global $int,$if_item,$items,$act_tag;
   if ($attr == 'ITEM' && $if_item == 0) {
      $items[$int] = new item($int,null);
      $if_item=1;
   }
   if ($if_item == 1) 
      $act_tag = $attr;
}

function tag_end($parser,$attr) {
   global $act_tag, $int, $if_item;
   
   if ($attr == 'ITEM' && $if_item == 1) { 
      $int++;   
      $if_item=0;
   }
}
function tag_text($parser,$text) {
   global $act_tag,$int,$if_item,$items,$nagelforum;
   if ($if_item == 1) {
      switch($act_tag) {
         case 'DESCRIPTION' :  $items[$int]->desc.= $text; break;
	 case 'TITLE':	if ($nagelforum == 0) {
			   $tmp=$text;
			   $pos=strpos($text,':');
			   $category=substr($text,0,$pos-1);
			   $items[$int]->category.= $category;
			   $items[$int]->title.= substr($text,$pos+1);
			}
			else {
			   $items[$int]->category.= "Nagelforum ";
			   $items[$int]->title.= $text;
			}
			break;
         case 'LINK' : $items[$int]->link .= $text; break;
         case 'PUBDATE' : $items[$int]->pubDate .=$text; break; 
      }   
   }
}  

function parse_xml($file,$nagelforum1,$codepage) {
   global $items,$nagelforum;
   $fp=fopen($file,"r");
   $nagelforum=$nagelforum1;

//create xml parser
   $parser=xml_parser_create($codepage);
//handler to xml object
   xml_set_element_handler($parser,'tag_start','tag_end');
//set tags as text
   xml_set_character_data_handler($parser,'tag_text');

   if (!$fp) {
      echo 'Cannon open xml file!';
      exit;
   }

   while ($data=fread($fp,4096)) {
      if (!xml_parse($parser,$data,feof($fp))) {
	 die(sprintf("XML Error: %s in line %d",xml_error_string(xml_get_error_code($_parser)),xml_get_current_line_number($parser)));
   }
}
//free parser
   xml_parser_free($parser);
//sort by date
   fclose($fp);
   return $items;
}

jako parametry do funkcji parse_xml podaje url do pliku rss, nagelforum - sposob parsowania, i kodowanie jakie ma byc uzyte.
Nastpenie includuje ten plik i w jednym dokumencie uzywam dwukrotnie parse_xml ale z innymi kanalami rss, ktore zawiera inne kodowanie. testowalem to wszystko pod krasnalem i chodzilo, wrzucilem na serwer i chodzi, ale jak lokanie postawilem sobie xampp (ma duzo nowsze wersje php,mysql i itd niz krasnal) to mi nie chce parsowac, nie wyrzuca zadnych bledow. czy to ma jakis zwiazek z nowszym php (xampp 5.1.4 natomiast na krasnalu testowalem na 4.x.x ??

0

testowalem na krasnalu na php5 i tez nie chodzi wiec jest kwestia wersji php, czy wie ktos jak temu zaradzic?


problem rozwiazany.

1 użytkowników online, w tym zalogowanych: 0, gości: 1