Ciao a tutti ho il seguente problema:
voglio leggere un file xml e inserirlo in un array...
... quasi tutto fatto tranne la creazione dell'array.
Lo so, mi sta sfuggendo qualche cosa di semplice ma !!!

questo è il code
Codice PHP:
<?php
 $Path
="file.xml";   
 
$Risultato=array();
 if (
file_exists($Path))
  {
   
$Risposta=Array();
   
$xml = new XMLReader();
   
$xml->open($Path); 
   
$NodePath=array();
   
$NumNodePath=0;
   while(
$xml->read()) 
    {
     
$NodeType=$xml->nodeType;   
     if (
$NodeType==XMLReader::ELEMENT)
      {
       
$Nome=$xml->name;
       
$isEmptyElement=$xml->isEmptyElement;
       
$HasAttribute=$xml->hasAttributes;
       if (
$NumNodePath==0)
        {
         print 
"<font color='red'>creo path</font>
"
;
            
$Risultato[$Nome]=array();
         
$NumNodePath++;
         
$NodePath[$NumNodePath]=$Nome;
        }
       else
        {
         
$NumNodePath++;
         print 
"<font color='red'>aggiungo path $NumNodePath $Nome</font>
"
;
         
$NodePath[$NumNodePath]=$Nome;         
        }
         
$Valore=$xml->readOuterXML();
        if (
$HasAttribute)
         {
          
$xml->moveToNextAttribute();
          
$AttName=$xml->name;
          
$AttValu=$xml->value;
          print 
"<font color='red'>aggiungo path $NumNodePath $AttName $AttValu</font>
"

          
$Valore="($AttName=$AttValu)$Valore";
         }
      }
     if(
$NodeType == XMLReader::END_ELEMENT)
      {
       
$Nome=$xml->name;
       if (isset(
$Valore) && $Valore!="")
        {
         
$RelPath="";
         for (
$N=1$N<=$NumNodePath$N++)
          {
           
$RelPath=$RelPath."[".$NodePath[$N]."]";
          }
         print 
"<font color='blue'>RelPath=$RelPath =$Valore</font>
"
;
         unset(
$NodePath[$NumNodePath]);
         
$NumNodePath--;
        }
       
$Valore="";
      }
    }
  }
  
?>
E questo il file xml

codice:
<?xml version="1.0"?>
<voti>
 <materia>italiano</materia>
 <classi>
  <anno>1</anno>
  <sezione>a</sezione>
  <alunni>
   <alunno numero="1">6</alunno>
   <alunno numero="2">5</alunno>
   <alunno numero="3">6</alunno>
   <alunno numero="4">6</alunno>
   <alunno numero="5">3</alunno>
   <alunno numero="6">9</alunno>
   <alunno numero="7">2</alunno>
   <alunno numero="8">6</alunno>
  </alunni>
 </classi>
</voti>

Il risulto finalre dovrebbe essere l'array che viene scritto in blue quando si lancia lo script.

ps: ho lasciato in rosso gli alri output di debug/info.

Grazie a tutti