Tema: Parser XML
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/02/2005, 02:05
kez0
 
Fecha de Ingreso: enero-2004
Mensajes: 431
Antigüedad: 20 años, 3 meses
Puntos: 6
Parser XML

Veran he leido el articulo de zonaphp.com y he tomado su codigo pero al tratar de modificarlo no me sirve
Aqui el codigo:
Código PHP:
<? 
  
// parser de rss 
   
  // obtenemos el rss desde el sitio de zonaphp :) 
  
if(!($fp fopen("http://steamid.com/ircbot.php?qvalue=0:0:205893""r"))) 
  { 
   die(
"No puedo abrir el archivo!"); 
  } 
   
  
$rss ""
  while(!
feof($fp)) 
  { 
   
$rss .= fread($fp4096); 
  } 
  
fclose($fp); 
   
  
// inicializamos los auxiliares 
  
$contenido ""
  
$tag_actual ""
  
$en_item false
  
$item 0

  
// inicializamos arrays 
  
$items = Array(); 
   
  
// creamos el parser 
  
$parser xml_parser_create(); 
   
  
// definimos los "handlers" 
  
xml_set_element_handler($parser"tag_abre""tag_cierra"); 
  
xml_set_character_data_handler($parser"tag_contenido"); 
   
  
// declaramos las funciones 
  
function tag_abre($parser$nombre$atributos
  { 
   global 
$tag_actual$en_item

   
$tag_actual $nombre

   switch(
$nombre
   { 
    case 
"RESULT"
      
$en_item true
     break; 
   } 
  } 

  function 
tag_contenido($parser$valor
  { 
   global 
$contenido

   
$contenido .= $valor
  } 

  function 
tag_cierra($parser$nombre
  { 
   global 
$tag_actual$contenido$item$en_item,$items

   
$contenido trim($contenido); 

   switch(
$nombre
   { 
    case 
"PLAYER_STEAMID"
        if(
$en_item) {
       
$items[$item]["PLAYER_STEAMID"] = $contenido;
    }
     break; 
    case 
"TEAM_LEAGUE"
                if(
$en_item) {

        
$items[$item]["TEAM_LEAGUE"] = $contenido
    }
     break; 
    case 
"TEAM_NAME"
                if(
$en_item) {

       
$items[$item]["TEAM_NAME"] = $contenido
    }
     break; 
         case 
"TEAM_IRC"
                     if(
$en_item) {

       
$items[$item]["TEAM_IRC"] = $contenido
         }
     break; 
 case 
"PLAYER_NAME"
             if(
$en_item) {

       
$items[$item]["PLAYER_NAME"] = $contenido
 }
     break; 
   } 

   
$tag_actual ""
   
$contenido ""
  } 
   
  
// procedemos a procesar el archivo, en caso de error 
  // lo indicamos y terminamos 
  
if(!xml_parse($parser$rsstrue)) 
  { 
   die(
"Error en la linea "
       
xml_get_current_line_number($parser). 
       
": ".xml_error_string(xml_get_error_code($parser))); 
  } 
   
  
// destruimos el parser 
  
xml_parser_free($parser); 

  print 
$item["PLAYER_STEAMID"];
  print 
$item["TEAM_LEAGUE"];
  print 
$item["TEAM_NAME"];
  print 
$item["TEAM_IRC"];
  print 
$item["PLAYER_NAME"];
?>
Al ejecutarlo me muestra la pantalla en blanko
Alguna idea?

__________________
El que teme preguntar, se averguenza de aprender.