Convert xpath to linq

Topics: Developer Forum
Feb 1, 2015 at 6:56 AM
Edited Feb 1, 2015 at 6:58 AM
Hi all, i am trying to extract the info in winRT based on the following HTML:
<ul class="list-movie">
    <li class="movie-item">
        <a class="block-wrapper" title="My Title 1" href="/title1.html">
            <div class="thumbnail" style="background:url(http://mywebsite.net/film/poster.thumb.jpg); background-size: cover;"></div>
            <div class="meta">
                <span class="movie-title">movie 1</span>
                <span class="movie-duration">92 min</span>
            </div>
        </a>
    </li>
                            
    <li class="movie-item">
        <a class="block-wrapper" title="My Title 2" href="/title2.html">
            <div class="thumbnail" style="background:url(http://mywebsite.net/film/poster.thumb.jpg); background-size: cover;"></div>
            <div class="meta">
                <span class="movie-title">movie 2</span>
                <span class="movie-duration">117 min</span>
            </div>
        </a>
    </li>
</ul>
I have already done it in xpath for WP8, but unfortunally WinRT dont support xpath. Here is my code i've used to extract via xpath. Would be glad if someone is able to help me translate it for WinRT using the Descendants().
List<Movie> movie_list = new List<Movie>();
HtmlNodeCollection li = doc.DocumentNode.SelectNodes("//ul[@class='list-movie']//li");
                foreach (HtmlNode node in li)
                {
                    Movie m = new Movie();
                    var spanNodes = node.SelectNodes(".//span");
                    m.Title = spanNodes[0].InnerText;
                    m.Duration = StringHelper.ExtractNumber(spanNodes[1].InnerText);
                    HtmlNode ImgDiv = node.SelectSingleNode(".//div[@class='thumbnail']");
                    string style = ImgDiv.Attributes["style"].Value;
                    m.Thumbnail = new Uri(Regex.Match(style, @"(?<=\().+?(?=\))").Value);
                    m.MovieURL = node.Element("a").Attributes["href"].Value;
                    movie_list.Add(m);
                }