T
Tony Johansson
Hi!
Here I use LINQ to XML. What I want is to load the following elements
title, runningLength, productionYear,url and isbnNumber into a generic
collection of Movie object.
By code works but I find it far to long. It must be possible to make this
code much shorter.
List<Movie> movies = new List<Movie>();
var myMovies = from movie in
XDocument.Load(TextboxURL.Text).Descendants("movie")
select new
{
title = movie.Element("title").Value,
runningLength = movie.Element("runningLength").Value,
productionYear = movie.Element("productionYear").Value,
url = movie.Element("url").Value,
isbnNumber = movie.Element("isbnNumber").Value
};
foreach (var movie in myMovies )
{
movies.Add(new Movie( movie.title, movie.url,Convert.ToInt32
(movie.runningLength),movie.productionYear,movie.isbnNumber));
}
//Tony
Here I use LINQ to XML. What I want is to load the following elements
title, runningLength, productionYear,url and isbnNumber into a generic
collection of Movie object.
By code works but I find it far to long. It must be possible to make this
code much shorter.
List<Movie> movies = new List<Movie>();
var myMovies = from movie in
XDocument.Load(TextboxURL.Text).Descendants("movie")
select new
{
title = movie.Element("title").Value,
runningLength = movie.Element("runningLength").Value,
productionYear = movie.Element("productionYear").Value,
url = movie.Element("url").Value,
isbnNumber = movie.Element("isbnNumber").Value
};
foreach (var movie in myMovies )
{
movies.Add(new Movie( movie.title, movie.url,Convert.ToInt32
(movie.runningLength),movie.productionYear,movie.isbnNumber));
}
//Tony