Ver Mensaje Individual
  #16 (permalink)  
Antiguo 19/04/2012, 14:40
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: ¿Como mostrar el numero de resultados de una consulta a un XML condicionad

Disculpa por no responder rápido pero realmente no tenía tiempo...

Si entre mensaje tienes titulo y genero, podrías hacer algo así:

Código PHP:
Ver original
  1. <?php
  2. $library = new SimpleXMLElement('test.xml', null, true);
  3. $ti = $library->xpath('(//mensaje[genero="Rock"]/titulo)[position() <= 20]');
  4.  
  5. foreach ($ti as $t) {
  6.     echo $t . '<br />';
  7. }

Mostraría los títulos de los primeros 20 mensajes del genero Rock.

Ahora si lo que quieres es un condicional que te muestre del 20 al 40, puedes hacer algo así:

Código PHP:
Ver original
  1. <?php
  2. $library = new SimpleXMLElement('test.xml', null, true);
  3. $ti = $library->xpath('(//mensaje[genero="Rock"]/titulo)[(position() >= 20)  and (position() <= 40)]');
  4.  
  5. foreach ($ti as $t) {
  6.     echo $t . '<br />';
  7. }

Espero que te sirva, saludos.
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP