Ver Mensaje Individual
  #4 (permalink)  
Antiguo 24/01/2012, 12:30
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 13 años, 6 meses
Puntos: 793
Respuesta: attributes img CDATA xml php

Algo así mas o menos, la imagen con el valor de la temperatura:

Código PHP:
Ver original
  1. <?php
  2. $doc = new DOMDocument();
  3. $xml = file_get_contents('http://weather.yahooapis.com/forecastrss?w=2502265');
  4. $doc->loadXML($xml);
  5. $des = $doc->getElementsByTagName('description');
  6.  
  7. $con = $doc->getElementsByTagNameNS($doc->lookupNamespaceUri('yweather'), 'condition');
  8. $temp = $con->item(0)->attributes->getNamedItem('temp')->nodeValue;
  9.  
  10. $doc->loadHTML($des->item(1)->nodeValue);
  11. $imgs = $doc->getElementsByTagName('img');
  12. $img = $imgs->item(0)->attributes->getNamedItem('src')->nodeValue;
  13. ?>
  14. <img src="<?php echo $img; ?>" /><br />
  15. <?php echo $temp . ' F'; ?>
__________________
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