Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/02/2012, 19:01
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: Extraer html en id's concretas

Es mucho mejor usar DOM, si se dispone de estas clases:

Código PHP:
Ver original
  1. <?php
  2. $html = '<!DOCTYPE html><html><body>
  3. Test<br />
  4. <img src="myimage.jpg" title="title" alt="alt" id="imagen" />
  5. <img src="myimage2.jpg" title="title" alt="alt" />
  6. </body></html>';
  7.  
  8. $doc = new DOMDocument();
  9. $doc->loadHTML($html);
  10.  
  11. echo $doc->getElementById('imagen')
  12.     ->attributes
  13.     ->getNamedItem('src')
  14.     ->nodeValue;
  15.     //myimage.jpg

http://www.php.net/manual/es/book.dom.php
__________________
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