tags:

views:

375

answers:

2

Hello how i can read XML from youtube

    $xml = new XMLReader();
 $xml->open('http://gdata.youtube.com/feeds/api/videos/1uwOL4rB-go');


 $r = array();
 while($xml->read()) {
  $r[] = array($xml->name => $xml->value);
 }

i got this far but it doesnt get the necesary info i need like video duration....

+1  A: 

The duration is stored in the yt:duration node, under the media:group aggregate.

What language are you using? There are client libraries created by Google for Java, .Net, Python, PHP, and Objective C. There is also WebService::YouTube on CPAN if you are using Perl.

pkaeding
i use php for getting info
Krišjanis
I'd definitely recommend using the client library (http://code.google.com/apis/youtube/code.html#PHP) then, rather than deconstructing the XML yourself.
pkaeding
+1, use an API whenever available. Also, I should mention that XMLReader is just about the most complicated way to read an XML document. If you have to handle some XML, try SimpleXML instead.
Josh Davis
A: 

this was already seen in multiple flavors, simplexml and domdocument : http://stackoverflow.com/questions/2212009/simplexml-returning-multiple-objects-how-can-i-get-the-data

useless