Oto kod prasera XML:
  1. <?php
  2.  
  3.  $_GET['file'] = 'raport.xml';
  4.  
  5.  function tag_start($parser, $attr, $params){
  6. global $mecz, $act_tag;
  7. $act_tag = $attr;
  8.  }
  9.  
  10.  function tag_text($parser, $text){
  11. global $mecz, $act_tag;
  12. $mecz[$act_tag] = $text;
  13.  }
  14.  function tag_end($parser, $attr){
  15.  }
  16.  
  17.  
  18.  $parser = xml_parser_create();
  19.  xml_set_element_handler($parser, 'tag_start', 'tag_end');
  20.  xml_set_character_data_handler($parser, 'tag_text');
  21.  $fp = fopen($_GET['file'], "r");
  22.  
  23.  while($data = fread($fp, 4096)) {
  24. xml_parse($parser, $data, feof($fp));
  25.  }
  26.  
  27.  xml_parser_free($parser);
  28.  
  29.  foreach($mecz as $pole => $wartosc)
  30.  {
  31.  echo '<b>'.$pole.':</b> '.$wartosc.'<br>';
  32.  }
  33.  
  34. ?>


W pętli foreach wyświetla mi się tylko $pole, a $wartosc juz nie.
Myśle że to coś z zasięgiem zmiennych bo gdy w funkcji tag_text() wstawiam
  1. <?php
  2. echo $text;
  3. ?>
zmienna się prawidłowo wyświetla.

Z góry dzięki za pomoc.