Re: SimpleXML strange behaviour.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mirco Soderi schrieb:
Do you know any reason why the following code does work


$xmlOperazioni = simplexml_load_file($xmlFilename);
foreach($xmlOperazioni->operazione as $operazione) {
   if($operazione['nome'] == $operazioneRichiesta) {
      require($operazione['php']);
      break;
   }
}

but the following does not

$xmlOperazioni = simplexml_load_file($impostazioni['root']['configurazione']['generale']['xml_operazioni']);
foreach($xmlOperazioni->operazione as $operazione) {
   if($operazione->nome == $operazioneRichiesta) {
      require($operazione->php);
      break;
   }
}

that is I MUST access childrens of the element <operazione> as if it was an array, while (in the same page) the following code does work

$xmlViste = simplexml_load_file($impostazioni['root']['configurazione']['generale']['xml_composizione_viste']);
foreach($xmlViste->vista as $vista) {
    if($vista->nome == $nomeVistaDaMostrare) {
       $smarty->assign("intestazione","componenti/".$vista->intestazione);
       $smarty->assign("menu","componenti/".$vista->menu);
       $smarty->assign("contenuto", "componenti/".$vista->contenuto);
       $smarty->assign("pie_di_pagina", "componenti/".$vista->pie_di_pagina);
       break;
    }
}

but the following does not

$xmlViste = simplexml_load_file($impostazioni['root']['configurazione']['generale']['xml_composizione_viste']);
foreach($xmlViste->vista as $vista) {
    if($vista['nome'] == $nomeVistaDaMostrare) {
       $smarty->assign("intestazione","componenti/".$vista['intestazione']);
       $smarty->assign("menu","componenti/".$vista['menu']);
       $smarty->assign("contenuto", "componenti/".$vista['contenuto']);
       $smarty->assign("pie_di_pagina", "componenti/".$vista['pie_di_pagina']);
       break;
    }
}

that is this time I MUST access the childrens of the element <operazione> as if it was an object?
Hi,
it is too dificult to say without the XML file youre try to load.


Regards

Carlos

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux