Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [XML][PHP] Problem z pobranie atrybutu tagu XML
shinuexx
post 2.03.2011, 20:17:00
Post #1





Grupa: Zarejestrowani
Postów: 78
Pomógł: 9
Dołączył: 2.02.2011
Skąd: undefined

Ostrzeżenie: (0%)
-----


Witam
Mam taki problem z przetworzeniem za pomocą DOM w php takiego XML:
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
  3. <id>http://gdata.youtube.com/feeds/api/videos/QtB_i-uDxLI</id>
  4. <published>2009-06-18T13:14:07.000Z</published>
  5. <updated>2011-02-27T22:24:06.000Z</updated>
  6. <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>
  7. <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='People' label='Ludzie i blogi'/>
  8. <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Не зарекайся'/>
  9. <title type='text'>БАНД`ЭРОС "Не зарекайся"</title>
  10. <content type='text'/>
  11. <link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=QtB_i-uDxLI&amp;feature=youtube_gdata'/>
  12. <link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/QtB_i-uDxLI/responses'/>
  13. <link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/QtB_i-uDxLI/related'/>
  14. <link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/QtB_i-uDxLI'/>
  15. <author>
  16. <name>BanderosOfficial</name>
  17. <uri>http://gdata.youtube.com/feeds/api/users/banderosofficial</uri>
  18. </author>
  19. <gd:comments>
  20. <gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/QtB_i-uDxLI/comments' countHint='7'/>
  21. </gd:comments>
  22. <media:group>
  23. <media:category label='Ludzie i blogi' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>People</media:category>
  24. <media:content url='http://www.youtube.com/v/QtB_i-uDxLI?f=videos&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='233' yt:format='5'/>
  25. <media:content url='rtsp://v5.cache4.c.youtube.com/CiILENy73wIaGQmyxIPri3_QQhMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='233' yt:format='1'/>
  26. <media:content url='rtsp://v8.cache4.c.youtube.com/CiILENy73wIaGQmyxIPri3_QQhMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='233' yt:format='6'/>
  27. <media:description type='plain'/>
  28. <media:keywords>Не зарекайся</media:keywords>
  29. <media:player url='http://www.youtube.com/watch?v=QtB_i-uDxLI&amp;feature=youtube_gdata_player'/>
  30. <media:thumbnail url='http://i.ytimg.com/vi/QtB_i-uDxLI/0.jpg' height='240' width='320' time='00:01:56.500'/>
  31. <media:thumbnail url='http://i.ytimg.com/vi/QtB_i-uDxLI/1.jpg' height='90' width='120' time='00:00:58.250'/>
  32. <media:thumbnail url='http://i.ytimg.com/vi/QtB_i-uDxLI/2.jpg' height='90' width='120' time='00:01:56.500'/>
  33. <media:thumbnail url='http://i.ytimg.com/vi/QtB_i-uDxLI/3.jpg' height='90' width='120' time='00:02:54.750'/>
  34. <media:title type='plain'>БАНД`ЭРОС "Не зарекайся"</media:title>
  35. <yt:duration seconds='233'/>
  36. </media:group>
  37. <gd:rating average='4.9633026' max='5' min='1' numRaters='109' rel='http://schemas.google.com/g/2005#overall'/>
  38. <yt:statistics favoriteCount='130' viewCount='41513'/>
  39. </entry>

Jest to XML z danymi z youtube'a. Znajduje się tam tag:
  1. <yt:duration seconds='233'/>

i nie mogę sobie poradzić z wyświetleniem wartości atrybutu seconds.

Próbowałem takiego kodu:
  1. $info = new DOMDocument();
  2. $info->load("http://gdata.youtube.com/feeds/api/videos/".$movie);
  3. $timesec=$info->getElementsByTagNameNS('yt','duration')->item(0)->getAttribute('second');

a także bez item(0) ale i to nie działa. Na necie nie znalazłem rozwiązania swojego problemu bo znalezione przeze mnie nie działa.
Proszę o pomoc.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 20:11