特定のチャンネルにアップロードされたすべての動画を含む XML ファイルを解析しようとしています。<media:content>
いずれかのノードで URL 属性の値を取得し、それを ViewerLocation フィールドに入れようとしています。ただし、それらのいくつかがあります。私の現在のコードはこれです:
var videos = from xElem in xml.Descendants(atomNS + "entry")
select new YouTubeVideo()
{
Title = xElem.Element(atomNS + "title").Value,
Description = xElem.Element(atomNS + "content").Value,
DateUploaded = xElem.Element(atomNS + "published").Value,
ThumbnailLocation = xElem.Element(mediaNS + "group").Element(mediaNS + "content").Attribute("url").Value,
ViewerLocation = xElem.Element(mediaNS + "group").Element(mediaNS + "content").Attribute("url").Value
};
<media:content>
期待どおりの名前で、エントリ用の XML の最初のノードを取得します。ただし、XML の最初のエントリは、私が望むものではありません。2番目が欲しい。
以下は、関連する XML です。
<!-- I currently get the value held in this node -->
<media:content
url='http://www.youtube.com/v/ZTUVgYoeN_b?f=gdata_standard...'
type='application/x-shockwave-flash' medium='video'
isDefault='true' expression='full' duration='215' yt:format='5'/>
<!-- What i actually want is this one -->
<media:content
url='rtsp://rtsp2.youtube.com/ChoLENy73bIAEQ1kgGDA==/0/0/0/video.3gp'
type='video/3gpp' medium='video'
expression='full' duration='215' yt:format='1'/>
<media:content
url='rtsp://rtsp2.youtube.com/ChoLENy73bIDRQ1kgGDA==/0/0/0/video.3gp'
type='video/3gpp' medium='video'
expression='full' duration='215' yt:format='6'/>
タイプが「video/3gpp」であるため、2 番目のノードが必要です。それを選択するにはどうすればよいですか?私の論理は
if attribute(type == "video/3gpp") はこの値を取得します。
しかし、これをLinqで表現する方法がわかりません。
ありがとう、
ダニー。