locked
first project RRS feed

  • Question

  •  I'm posting this code to see if anybody would have any suggestions for a better way to this. It gets the image and title from a netflix xml file and puts it in a list. It  works but it seems like I might have done more then I needed to and made it more complicated then it needs to be. Any comments or suggestions would be greatly appreciated.

    Heres the code:

    private void PopulateQueueView()

    {

    string QueueUrl = ("http://rss.netflix.com/QueueRSS?id="+ NetflixRSSID);

    XmlDocument QueueDoc = new XmlDocument();

    QueueDoc.Load(QueueUrl);

    XmlNodeList TitleData = QueueDoc.GetElementsByTagName("title");

    XmlNodeList LinkData = QueueDoc.GetElementsByTagName("link");

    XmlNodeList DescriptionData = QueueDoc.GetElementsByTagName("description");

    int count = TitleData.Count;

    int i;

    for (i = 1; i < count; i++)

    {

    string Description = DescriptionData[i].InnerXml;

    Regex Exp = new Regex("(?<=img src=[\x27\x22])(?<Url>[^\x27\x22]*)(?=[\x27\x22])", RegexOptions.Singleline);

    Match IdString = Exp.Match(Description);

    Group result = IdString.Groups["Url"];

    Grid lvigrid = new Grid();

    lvigrid.Margin = new Thickness(0, 0, 5, 0);

    lvigrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;

    RowDefinition imgrow = new RowDefinition();

    RowDefinition titlerow = new RowDefinition();

    imgrow.Height = new GridLength(0, GridUnitType.Auto);

    titlerow.Height = new GridLength(0, GridUnitType.Auto);

    lvigrid.RowDefinitions.Add(imgrow);

    lvigrid.RowDefinitions.Add(titlerow);

    TextBlock title = new TextBlock();

    title.TextAlignment = TextAlignment.Center;

    string temptext = TitleData[i].InnerXml.ToString();

    char[] MyChar = { '0' };

    string text = temptext.TrimStart(MyChar);

    title.Text = text;

    title.FontFamily = new System.Windows.Media.FontFamily("ariel");

    title.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;

    title.FontSize = 12;

    title.Width = 116;

    title.TextTrimming = TextTrimming.WordEllipsis;

    Image img = new Image();

    img.Margin = new Thickness(0, 3, 0, 3);

    img.Width = 112;

    img.Height = 122;

    BitmapImage bmp = new BitmapImage(new Uri(result.Value));

    img.Source = bmp;

    lvigrid.Children.Add(img);

    lvigrid.Children.Add(title);

    Grid.SetRow(img, 0);

    Grid.SetRow(title, 1);

    lvigrid.ToolTip = title.Text;

    lvigrid.Tag = LinkData[i].InnerText;

    QueueListview.Items.Add(lvigrid);

    }

    QueuePop = 1;

    }

    Friday, June 20, 2008 2:01 AM