невозможно запросить каждый элемент из этого XML. я должен получить название, идентификатор, - PullRequest
0 голосов
/ 25 августа 2010
<?xml version='1.0' encoding='UTF-8'?>
<feed >
<id>http://gdata.youtube.com/feeds/api/videos</id>
<updated>2010-08-24T13:18:29.767Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>
<title type='text'>YouTube Videos matching query: aa</title>
<logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo>
<link rel='alternate' type='text/html' href='http://www.youtube.com'/>
<link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos'/>
<link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/batch'/>
<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos?q=aa&amp;start-index=1&amp;max-results=25'/>
<link rel='next' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos?q=aa&amp;start-index=26&amp;max-results=25'/>

<author>
    <name>YouTube</name>
 <uri>http://www.youtube.com/</uri>
</author>


<generator version='2.0' uri='http://gdata.youtube.com/'>YouTube data API</generator>


<openSearch:totalResults>484223</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>

<openSearch:itemsPerPage>25</openSearch:itemsPerPage>

<entry>

 <id>http://gdata.youtube.com/feeds/api/videos/p4ebtj1jR7c</id>

 <published>2007-12-30T23:11:39.000Z</published>

 <updated>2010-08-24T02:30:36.000Z</updated>

 <category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Tech' label='Science &amp; Technology'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='AA-12'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='AA'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='12'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='AA12'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='automatic'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='shotgun'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='weapon'/>

 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='weapons'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='military'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='hardware'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='assault'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='blackwater'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='firearms'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='army'/>
 <category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='american'/>

 <title type='text'>AA-12. World's deadliest shotgun!</title>


 <content type='text'>weblink: tinyurl.com Blackwater firearms: www.blackwaterusa.com</content>

 <link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=p4ebtj1jR7c&amp;feature=youtube_gdata'/>
 <link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/p4ebtj1jR7c/responses'/>
 <link rel='http://gdata.youtube.com/schemas/2007#video.ratings' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/p4ebtj1jR7c/ratings'/>
 <link rel='http://gdata.youtube.com/schemas/2007#video.complaints' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/p4ebtj1jR7c/complaints'/>
 <link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/p4ebtj1jR7c/related'/>
 <link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=p4ebtj1jR7c'/>
 <link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/p4ebtj1jR7c'/>


 <author><name>MFS357</name><uri>http://gdata.youtube.com/feeds/api/users/mfs357</uri></author><gd:comments><gd:feedLink href='http://gdata.youtube.com/feeds/api/videos/p4ebtj1jR7c/comments' countHint='15208'/></gd:comments><media:group><media:category label='Science &amp; Technology' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Tech</media:category><media:content url='http://www.youtube.com/v/p4ebtj1jR7c?f=videos&amp;d=ARZEzGI7ejBt-fukjjc3kIAO88HsQjpE1a8d1GxQnGDm&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='384' yt:format='5'/><media:content url='rtsp://v3.cache3.c.youtube.com/CkULENy73wIaPAm3R2M9tpuHpxMYDSANFEgGUgZ2aWRlb3NyIQEWRMxiO3owbfn7pI43N5CADvPB7EI6RNWvHdRsUJxg5gw=/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='384' yt:format='1'/><media:content url='rtsp://v4.cache8.c.youtube.com/CkULENy73wIaPAm3R2M9tpuHpxMYESARFEgGUgZ2aWRlb3NyIQEWRMxiO3owbfn7pI43N5CADvPB7EI6RNWvHdRsUJxg5gw=/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='384' yt:format='6'/><media:description type='plain'>weblink: tinyurl.com Blackwater firearms: www.blackwaterusa.com</media:description><media:keywords>AA-12, AA, 12, AA12, automatic, shotgun, weapon, weapons, military, hardware, assault, blackwater, firearms, army, american</media:keywords><media:player url='http://www.youtube.com/watch?v=p4ebtj1jR7c&amp;feature=youtube_gdata_player'/><media:thumbnail url='http://i.ytimg.com/vi/p4ebtj1jR7c/2.jpg' height='90' width='120' time='00:03:12'/><media:thumbnail url='http://i.ytimg.com/vi/p4ebtj1jR7c/1.jpg' height='90' width='120' time='00:01:36'/><media:thumbnail url='http://i.ytimg.com/vi/p4ebtj1jR7c/3.jpg' height='90' width='120' time='00:04:48'/><media:thumbnail url='http://i.ytimg.com/vi/p4ebtj1jR7c/0.jpg' height='240' width='320' time='00:03:12'/><media:title type='plain'>AA-12. World's deadliest shotgun!</media:title><yt:duration seconds='384'/></media:group><gd:rating average='4.774384' max='5' min='1' numRaters='12180' rel='http://schemas.google.com/g/2005#overall'/><yt:statistics favoriteCount='27463' viewCount='7607670'/></entry></feed>

необходимо извлечь заголовок, идентификатор и другие внутренние значения из этого xml, пробовали как xml.feed.title и другие опции для ...

Ответы [ 2 ]

1 голос
/ 25 августа 2010

Переменная xml относится к самому корневому тегу. Так что вам не нужно ссылаться на feed в вашем e4x.

var feed:XML = new XML(theString);
trace(feed.entry.title);
trace(feed.entry.id);
trace(feed.entry.author.name);

Похоже, что xml использует некоторые пространства имен, такие как openSearch, gd и т. Д., Но их объявления отсутствуют.

0 голосов
/ 25 августа 2010

Для каждой записи видео вы можете пойти так:

xml.entry[index] //this will give you the XMLList for 'index' numbered video
xml.entry[index].title 
xml.entry[index].id  //these will give you title and id for corresponding videos 
...