PDA

Просмотр полной версии : XML parse


telit
29.05.2008, 02:06
такой вопрос: trace(entry.xml.toString());
выдает такое:
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:rte="http://www.rte.ie/schemas/vod">
<id>http://vod.rte.ie/videos/4rnGcQpDcyc</id>
<published>2008-02-21T07:56:58.000-08:00</published>
<updated>2008-04-30T07:06:00.000-07:00</updated>
<title type="text">Fair City</title>
<content type="text">Ali and Robin have a huge row front of the whole street. Jimmy can’t handle it and walks off but neither of them notices as they are still arguing. McAleer gives Tiernan and envelope containing a copy of Benjamin’s birth certificate.</content>
<category term="channel" label="RTE One"/>
<category term="genre" label="Drama"/>
<category term="series" label="Season 25"/>
<link rel="self" type="application/atom+xml" href="http://vod.rte.ie/videos/4rnGcQpDcyc"/>
<link rel="alternate" type="text/html" href="http://vod.rte.ie/app?id=4rnGcQpDcyc"/>
<link rel="embed" type="application/x-shockwave-flash" href="http://vod.rte.ie/player?id=4rnGcQpDcyc"/>
<rte:valid start="2008-04-30T07:06:00.000-07:00" end="2008-04-30T07:06:00.000-07:00"/>
<rte:duration ms="1234000" formatted="00:12"/>
<rte:statistics views="1282"/>
<author>
<name>RTE</name>
<uri>http://www.rte.ie</uri>
</author>
<media:title type="plain">Fair City</media:title>
<media:description type="plain">Ali and Robin have a huge row front of the whole street. Jimmy can’t handle it and walks off but neither of them notices as they are still arguing. McAleer gives Tiernan and envelope containing a copy of Benjamin’s birth certificate.</media:description>
<media:player url="http://vod.rte.ie/player?id=4rnGcQpDcyc" width="400" height="300"/>
<media:thumbnail url="http://dynamic.rte.ie/09786756.jpg" height="128" width="72" time="00:00:00.000"/>
<media:restriction relationship="allow" type="country">ie gb</media:restriction>
<media:rating>ma</media:rating>
<media:group>
<media:content url="rtmp://rtmp.rte.ie/vod/file1.mp4" type="video/mp4" medium="video" expression="full" duration="15000" rte:format="advertising"/>
<media:content url="rtmp://rtmp.rte.ie/vod/file2.mp4" type="video/mp4" medium="video" expression="full" duration="5000" rte:format="sting"/>
<media:content url="rtmp://rtmp.rte.ie/vod/file3.mp4" type="video/mp4" medium="video" expression="full" duration="1800000" rte:format="content"/>
<media:content url="rtmp://rtmp.rte.ie/vod/file4.mp4" type="video/mp4" medium="video" expression="full" duration="15000" rte:format="advertising"/>
<media:content url="rtmp://rtmp.rte.ie/vod/fil6e.mp4" type="video/mp4" medium="video" expression="full" duration="1800000" rte:format="content"/>
</media:group>
</entry>

Как получить массив "media:group"?

Skriv
29.05.2008, 08:54
trace(entry.media:group.text());

telit
30.05.2008, 10:46
Спасибо! Возник ещё один вопрос как получить доступ к такому аттрибуту:
rte:format="advertising"

etc
30.05.2008, 20:55
telit, вам привели синтаксически неверный код, у вас он что, работает?

vooparker
31.05.2008, 10:51
это особый, уличный код =)
2tellit: на вскидку, попробуй так

var media:Namespace = new Namespace("http://search.yahoo.com/mrss/");
var rte:Namespace = new Namespace("http://www.rte.ie/schemas/vod");
trace(entry.xml.media::group.*);
trace(entry.xml.media::group.media::content[0].@rte::format);

telit
08.06.2008, 12:42
Спасибо. Получилось, но появилась другая проблема
как вытащить "href" из <link...

etc
08.06.2008, 13:51
@href

telit
09.06.2008, 02:31
<link rel="self" type="application/atom+xml" href="http://vod.rte.ie/videos/4rnGcQpDcyc"/>
<link rel="alternate" type="text/html" href="http://vod.rte.ie/app?id=4rnGcQpDcyc"/>
<link rel="embed" type="application/x-shockwave-flash" href="http://vod.rte.ie/player?id=4rnGcQpDcyc"/>

как обратиться к 1,2 и 3 "link"?
XML представлен в начале темы.

vooparker
09.06.2008, 03:01
ну может уже справочник откроете? http://livedocs.adobe.com/flex/3/html/13_Working_with_XML_01.html

telit
09.06.2008, 11:34
for each (var prop:XML in entry.xml.link)
{
trace(prop);
}
Пробовал разобраться, не получается :(

BlooDHounD
09.06.2008, 12:25
не удивительно. начните с примеров по проще.

telit
09.06.2008, 13:22
Что значит "начните с примеров по проще."? у меня есть определённая задача и мне её надо решить.

BlooDHounD
09.06.2008, 13:38
а я не умею прыгать с парашюта! как вы думаете, если я прыгну без обучения, мои шансы велики?

ladon
09.06.2008, 14:14
for each (var prop:XML in entry.xml) {
}


и проверяем на линк каждый prop

ladon
09.06.2008, 14:16
if (prop.name().localName == "link") {
trace("link " + prop);
}

vooparker
09.06.2008, 14:34
2ladon: а не проще все таки e4x использовать, а не бегать циклом по всему что можно?

telit
09.06.2008, 14:51
if (prop.name().localName == "link") {
trace("link " + prop);
}
Не работает.

telit
09.06.2008, 14:57
for each (var prop:XML in entry.xml) {
trace("-------------"+prop);
}
Выдаёт prop - как весь xml а не по тегам

Сайлас
09.06.2008, 23:25
А что нужно? У пропа взять содержимое внутри тэгов? prop.toString(), имя тэга? prop.name().toString()
Если не понял в чем проблема - поясните :)
Upd: Понял в чем вопрос, чичас гляну...

Сайлас
09.06.2008, 23:42
Так я и не заметил, что у вас там неймспейс есть :)
var mainns:Namespace = new Namespace("http://www.w3.org/2005/Atom");
for each (var prop:XML in xml.mainns::link){
trace(prop);
}

telit
10.06.2008, 09:57
var mainns:Namespace = new Namespace("http://www.w3.org/2005/Atom");
for each (var prop:XML in entry.xml.mainns::link){
trace(prop);
}
Так заработало! Ура! Спасибо огромное!!!!

Сайлас
10.06.2008, 15:34
Ну у кого entry, а у меня просто var xml:XML = <entry ...></entry :)