Foros del Web » Programando para Internet » PHP »

Duda con Simple XML

Estas en el tema de Duda con Simple XML en el foro de PHP en Foros del Web. Amigos : quiero acceder a un atributo 'url', el que tiene el string 'rtsp://rtsp2.youtube.com/CiILENy73wIaGQnV5lZ4wj5RahMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' y sigo el array pero no puedo encontrar la forma de ...
  #1 (permalink)  
Antiguo 03/08/2009, 20:35
Avatar de Italico76  
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años
Puntos: 292
Exclamación Duda con Simple XML

Amigos: quiero acceder a un atributo 'url', el que tiene el string 'rtsp://rtsp2.youtube.com/CiILENy73wIaGQnV5lZ4wj5RahMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' y sigo el array pero no puedo encontrar la forma de accederlo:

var_dump($entry->mediaxgroup['mediaxcategory']); da 'NULL'

y...

var_dump($entry->mediaxgroup); da ...

Cita:
object(SimpleXMLElement)#9 (8) {
["mediaxcategory"]=>
string(5) "Howto"
["mediaxcontent"]=>
array(3) {
[0]=>
object(SimpleXMLElement)#10 (1) {
["@attributes"]=>
array(6) {
["url"]=>
string(63) "http://www.youtube.com/v/alE-wnhW5tU&f=videos&app=youtube_gdata"
["type"]=>
string(29) "application/x-shockwave-flash"
["medium"]=>
string(5) "video"
["isDefault"]=>
string(4) "true"
["expression"]=>
string(4) "full"
["duration"]=>
string(2) "93"
}
}
[1]=>
object(SimpleXMLElement)#11 (1) {
["@attributes"]=>
array(5) {
["url"]=>
string(89) "rtsp://rtsp2.youtube.com/CiILENy73wIaGQnV5lZ4wj5RahMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"
["type"]=>
string(10) "video/3gpp"
["medium"]=>
string(5) "video"
["expression"]=>
string(4) "full"
["duration"]=>
string(2) "93"
}
}
[2]=>
object(SimpleXMLElement)#12 (1) {
["@attributes"]=>
array(5) {
["url"]=>
string(89) "rtsp://rtsp2.youtube.com/CiILENy73wIaGQnV5lZ4wj5RahMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"
["type"]=>
string(10) "video/3gpp"
["medium"]=>
string(5) "video"
["expression"]=>
string(4) "full"
["duration"]=>
string(2) "93"
}
}
}
["mediaxdescription"]=>
string(79) "100% working tutorial howto download like a premium members on rapidshare . com"
["mediaxkeywords"]=>
string(113) "rapidshare, rapidhack, cheat, how, to, no, limit, bypass, leech, help, download, free, account, accounts, premium"
["mediaxplayer"]=>
object(SimpleXMLElement)#13 (1) {
["@attributes"]=>
array(1) {
["url"]=>
string(42) "http://www.youtube.com/watch?v=alE-wnhW5tU"
}
}
Del mismo modo fallo al intentar obtener las keywords haciendo :

Código PHP:
var_dump($entry->mediaxgroup['mediaxkeywords']); 
aca el programa hasta ahora......

Código PHP:
<?
// VIDEO PARSER ~ SIMPLE XML
  
  
$data file_get_contents('http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed');      
  
$data str_replace ('media:','mediax',$data); // cambio la clave del array
  
$xml simplexml_load_string($data);    
    
  foreach( 
$xml->entry as $entry)
  {
       
$title$entry->title// titulo del video
    
$descri$entry->content;  //descrip
    
$url $entry->link[0]['href'];
    
$keywords $entry->mediaxgroup['mediaxcontent']['mediaxkeywords'];
    
        echo 
'<pre>';
       
var_dump($entry->mediaxgroup['mediaxthumbnail']);
        echo 
'</pre>';
  }
?>

Alguna idea ?

[ GRACIAS ]
__________________
Salu2!

Última edición por Italico76; 03/08/2009 a las 21:39
  #2 (permalink)  
Antiguo 03/08/2009, 23:36
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Duda con Simple XML

mmm....

no quiero ser malo (como siempre) pero ¿ya has revisado el manual al respecto??
http://www.php.net/manual/en/functio...attributes.php

digo, para que buscar ayuda aquí... si esta muy claro allá!!

__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 04/08/2009, 07:49
Avatar de Italico76  
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años
Puntos: 292
PATE .. lo lamento pero el manual esta MAL... el ejemplo del mismo no corre

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Specification mandate value for attribute b in C:\xampp\htdocs\test.php on line 8

Warning: simplexml_load_string() [function.simplexml-load-string]: <a xmlns:b> in C:\xampp\htdocs\test.php on line 8

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in C:\xampp\htdocs\test.php on line 8

Fatal error: Call to a member function attributes() on a non-object in C:\xampp\htdocs\test.php on line 9

Lo resolví pero al tanteo...... no entiendo como se cuando hay un nodo...
__________________
Salu2!

Última edición por GatorV; 04/08/2009 a las 10:48
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 05:05.