[BNM] SimpleXMLElement problem

Sebastian von Bischopink lists at allaboutseb.com
Tue Jun 5 13:42:49 BST 2007


Hello all,

i am having a little problem with SimpleXMLElement in php5, the XML i  
am parsing looks something like this:

<ROOT>
  <SPECTACLES>
     <SPECTACLE IDENT="10000059" NOM="Radioscopie de la Clarinette">
       <DEBUT>3/08/07</DEBUT>
       <FIN>5/08/07</FIN>
       <NUM_SAISON>10000001</NUM_SAISON>
       <TYPE/>
       <CATEG/>
       <AFFICHE>0</AFFICHE>
       <REPRESENTATIONS>
         <REPRESENTATION REP_DATE="3/08/07" REP_DISPO="150"  
REP_DUREE="01:20:00" REP_GRILLE="CINEMA GRILLE 2007"  
REP_GRILLE_WEB="" REP_HEURE="20:00:00" REP_ID="10000054" REP_INFO=""  
REP_NOM="Radioscopie de la Clarinette" REP_SALLE="10000009"/>
         <REPRESENTATION REP_DATE="4/08/07" REP_DISPO="150"  
REP_DUREE="01:20:00" REP_GRILLE="CINEMA GRILLE 2007"  
REP_GRILLE_WEB="" REP_HEURE="20:00:00" REP_ID="10000055" REP_INFO=""  
REP_NOM="Radioscopie de la Clarinette" REP_SALLE="10000009"/>
         <REPRESENTATION REP_DATE="5/08/07" REP_DISPO="150"  
REP_DUREE="01:20:00" REP_GRILLE="CINEMA GRILLE 2007"  
REP_GRILLE_WEB="" REP_HEURE="20:00:00" REP_ID="10000056" REP_INFO=""  
REP_NOM="Radioscopie de la Clarinette" REP_SALLE="10000009"/>
       </REPRESENTATIONS>
       <TEXTES>
         ...
       </TEXTES>
     </SPECTACLE>
   </SPECTACLES>
</ROOT>

I am checking the REP_DATE attribute and if it matches the concert  
date the description text is outputted.
This works fine for the first [REPRESENTATION] node, but I can not  
access the second or third one. This is the code i use:

if($xml->SPECTACLES->SPECTACLE[$i]->REPRESENTATIONS->REPRESENTATION 
['REP_DATE']==$concert_date)

but this only checks teh first and not the second or third one. I  
tried the following, but that doesn't work:

if($xml->SPECTACLES->SPECTACLE[$i]->REPRESENTATIONS->REPRESENTATION[0] 
['REP_DATE']==$concert_date or $xml->SPECTACLES->SPECTACLE[$i]- 
 >REPRESENTATIONS->REPRESENTATION[1]['REP_DATE']==$concert_date or  
$xml->SPECTACLES->SPECTACLE[$i]->REPRESENTATIONS->REPRESENTATION[2] 
['REP_DATE']==$concert_date)

Any hints on how to solve this? Thanks in advance,

Seb





More information about the BNMlist mailing list. Powered by Wessex Networks