Re: Atascado seleccionando datos en un xml.

From: Date: Mon, 16 Jun 2008 16:07:04 +0000
Subject: Re: Atascado seleccionando datos en un xml.
References: 1 2 3 4 5  Groups: php.general.es 
Request: Send a blank email to general-es+get-62777@lists.php.net to get a copy of this message
$tarif= simplexml_load_file('tarifa.xml'); foreach($tarif->grupo as $grupo){ if($grupo->id == $_POST["vehiculo"]){ foreach($grupo->dias as $dias){ foreach($dias->maxd as $maxdias){ echo $maxdias; } } } } asi tendria q funcionar On Mon, Jun 16, 2008 at 12:30 PM, Pablo Braulio <brulics@gmail.com> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Martin Scotta escribió: >> el problema lo tenes en la estructura del xml >> >> estas haciendo $id->dias cuando tu estructura es >> >> <grupo> >> <id>1</id> >> <dias> >> <maxd>2</maxd> >> <kmdia>500</kmdia> >> <precio>65,60</precio> >> >> deberias hacer $grupo->id y el foreach ($grupo->dias as $dia) o algo asi >> Mrtn >> > > No entiendo muy bien a lo que te refieres. > > Estoy haciendo $id->dias pues "dias" es el nombre del siguiente nodo > tras "id". > > Por otro lado si pongo en el tercer foreach $grupo->dias as $dia, me da > un error. > > > Warning: Invalid argument supplied for foreach() in... > > Si pudieras ponerme un ejemplo, te lo agradecería. > > Gracias por el comentario. > > - -- > > > < ¡¡Nos vemos!! > > ---------------------------- > \ > \ > .::!!!!!!!:. > .!!!!!:. .:!!!!!!!!!!!! > ~~~~!!!!!!. .:!!!!!!!!!UWWW$$$ > :$$NWX!!: .:!!!!!!XUWW$$$$$$$$$P > $$$$$##WX!: .<!!!!UW$$$$" $$$$$$$$# > $$$$$ $$$UX :!!UW$$$$$$$$$ 4$$$$$* > ^$$$B $$$$\ $$$$$$$$$$$$ d$$R" > "*$bd$$$$ '*$$$$$$$$$$$o+#" > """" """"""" > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFIVocVK7lGsMchFswRArcLAKC3zfU5jfFe5uRIOYsfb9mRQaNebACfdgU/ > no/G3UPRNnScdQXMPL8SwwQ= > =Azmx > -----END PGP SIGNATURE----- > > -- > PHP Spanish Localization Talk Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Martin Scotta http://www.echess.com.ar/ Decile NO al soft-pirata, usa Linux!

« previous php.general.es (#62777) next »