1
大家一直停留在這個有一段時間了,也不太清楚從這裏到XML元素7
去我一直在使用
void movie_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
return;
XElement xmlMovie = XElement.Parse(e.Result);
listBox1.ItemsSource = from movie in xmlMovie.Descendants("movies")
select new MovieItem
{
FilmName = movie.Element("movie").Element("alternative_name").Value,
overview = movie.Element("movie").Element("overview").Value,
rating = movie.Element("movie").Element("rating").Value,
filmurl = movie.Element("movie").Element("images").Element("image").Attribute("url").Value
};
listBox2.ItemsSource = from movie in xmlMovie.Descendants("movies")
// where movie.Element("movie").Element("images").Element("image").Attribute("size").Value == "cover"
select new MovieItem
{
rating = movie.Element("movie").Element("rating").Value
};
var urls = xmlMovie
.Descendants("image")
.Where(x => x.Attribute("size").Value == "cover")
.Select(x => x.Attribute("url").Value)
.ToArray();
}
public class MovieItem
{
public string FilmName { get; set; }
public string overview { get; set; }
public string Poster { get; set; }
public string rating { get; set; }
public string filmurl { get; set; }
}
}
這個XML
<movies>
<movie>
<score/>
<popularity>3</popularity>
<translated>true</translated>
<adult>false</adult>
<language>en</language>
<original_name>Batman</original_name>
<name>Batman</name>
<alternative_name>Batman (1989)</alternative_name>
<type>movie</type>
<id>268</id>
<imdb_id>tt0096895</imdb_id>
<url>http://www.themoviedb.org/movie/268</url>
<votes>29</votes>
<rating>8.1</rating>
<certification>PG-13</certification>
<overview>Gotham City: dark, dangerous, 'protected' only by a mostly corrupt police department. Despite the best efforts of D.A. Harvey Dent and police commissioner Jim Gordon, the city becomes increasingly unsafe...until a Dark Knight arises. Jack Napier, one-time enforcer for Boss Grissom, horribly disfigured after a firefight in a chemical factory...who, devoid of the last vestiges of sanity, seizes control of Gotham's underworld as the psychotic, unpredictable Clown Prince of Crime...the Joker.</overview>
<released>1989-06-23</released>
<images>
<image type="poster" url="http://cf2.imgobject.com/t/p/w92/a84j66FTKvobDFdaPEQ7eAQzbWU.jpg" size="thumb" width="92" height="138" id="4ea5d2bca34d4b37d20005c3"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/w154/a84j66FTKvobDFdaPEQ7eAQzbWU.jpg" size="w154" width="154" height="231" id="4ea5d2bca34d4b37d20005c3"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/w185/a84j66FTKvobDFdaPEQ7eAQzbWU.jpg" size="cover" width="185" height="278" id="4ea5d2bca34d4b37d20005c3"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/w342/a84j66FTKvobDFdaPEQ7eAQzbWU.jpg" size="w342" width="342" height="513" id="4ea5d2bca34d4b37d20005c3"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/w500/a84j66FTKvobDFdaPEQ7eAQzbWU.jpg" size="mid" width="500" height="750" id="4ea5d2bca34d4b37d20005c3"/>
<image type="poster" url="http://cf2.imgobject.com/t/p/original/a84j66FTKvobDFdaPEQ7eAQzbWU.jpg" size="original" width="1000" height="1500" id="4ea5d2bca34d4b37d20005c3"/>
<image type="backdrop" url="http://cf2.imgobject.com/t/p/w300/qDNiKJ46kQ6LHo9eyBK8u2QwRpF.jpg" size="thumb" width="300" height="169" id="4ea5d2b0a34d4b37d20005b9"/>
<image type="backdrop" url="http://cf2.imgobject.com/t/p/w780/qDNiKJ46kQ6LHo9eyBK8u2QwRpF.jpg" size="poster" width="780" height="439" id="4ea5d2b0a34d4b37d20005b9"/>
<image type="backdrop" url="http://cf2.imgobject.com/t/p/w1280/qDNiKJ46kQ6LHo9eyBK8u2QwRpF.jpg" size="w1280" width="1280" height="720" id="4ea5d2b0a34d4b37d20005b9"/>
<image type="backdrop" url="http://cf2.imgobject.com/t/p/original/qDNiKJ46kQ6LHo9eyBK8u2QwRpF.jpg" size="original" width="1920" height="1080" id="4ea5d2b0a34d4b37d20005b9"/>
</images>
<version>1242</version>
<last_modified_at>2012-03-05 19:39:45 UTC</last_modified_at>
</movie>
</movies>
}
現在我能夠使用我的選擇語句關閉url並正確顯示它,但是如何獲得url f或與大小=圖像「覆蓋」
在這一切的努力學習,因爲我一個人去很新,所以任何幫助將是巨大的:d
感謝
謝謝,我正在圍繞該方法......雖然仍然是一個律問題, – zeem 2012-03-07 14:37:38
它的工作原理,哪個問題? – 2012-03-07 14:56:31
看起來像它的工作,但有問題添加到我的列表框:/ – zeem 2012-03-07 15:49:35