Ver Mensaje Individual
  #4 (permalink)  
Antiguo 03/11/2008, 13:25
Avatar de Deschamps
Deschamps
 
Fecha de Ingreso: octubre-2008
Mensajes: 257
Antigüedad: 15 años, 7 meses
Puntos: 8
Respuesta: Pregunta sobre la lectura atributos en los tags

Aunque sea un poco "chapucero", si tienes el código en strings y jugando con expresiones regulares...

Código php:
Ver original
  1. <?php
  2.     function atributos( $cadena ) {
  3.         $patron  = '/[\'\"]([^\'^\"]*)[\'\"]/i';
  4.        
  5.         $total  = preg_match_all( $patron, $cadena, $coincidencias );
  6.         return $coincidencias[1];
  7.     }
  8.    
  9.     print_r( atributos("<feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/'>") );
  10.     print_r( atributos('<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">') );
  11. ?>

Daría esta salida:

Código:
Array
(
    [0] => http://www.w3.org/2005/Atom
    [1] => http://a9.com/-/spec/opensearch/1.1/
)
Array
(
    [0] => http://purl.org/rss/1.0/modules/content/
    [1] => http://wellformedweb.org/CommentAPI/
    [2] => 2.0
)
 
Un saludo.