Exemplo n.º 1
0
        private AmazonAlbum FillAlbum(XmlNode node)
        {
            AmazonAlbum album = new AmazonAlbum();

              foreach (XmlNode childNode in node)
              {
            if (childNode.Name == "ASIN")
              album.Asin = childNode.InnerText;

            if (childNode.Name == "SmallImage")
            {
              album.SmallImageUrl = GetNode(childNode, "URL");
              album.CoverWidth = GetNode(childNode, "Width");
              album.CoverHeight = GetNode(childNode, "Height");
            }

            if (childNode.Name == "MediumImage")
            {
              album.MediumImageUrl = GetNode(childNode, "URL");
              album.CoverWidth = GetNode(childNode, "Width");
              album.CoverHeight = GetNode(childNode, "Height");
            }

            if (childNode.Name == "LargeImage")
            {
              album.LargeImageUrl = GetNode(childNode, "URL");
              album.CoverWidth = GetNode(childNode, "Width");
              album.CoverHeight = GetNode(childNode, "Height");
            }

            if (childNode.Name == "ItemAttributes")
            {
              foreach (XmlNode attributeNode in childNode)
              {
            if (attributeNode.Name == "Artist")
              album.Artist = attributeNode.InnerText;

            if (attributeNode.Name == "Title")
              album.Title = attributeNode.InnerText;

            if (attributeNode.Name == "ReleaseDate")
              album.Year = attributeNode.InnerText;

            if (attributeNode.Name == "Binding")
              album.Binding = attributeNode.InnerText;

            if (attributeNode.Name == "Label")
              album.Label = attributeNode.InnerText;
              }
            }

            if (childNode.Name == "Tracks")
            {
              // The node starts with a "<Disc Number Node" , we want all subnodes of it

              List<List<AmazonAlbumTrack>> discs = new List<List<AmazonAlbumTrack>>();
              List<AmazonAlbumTrack> tracks = new List<AmazonAlbumTrack>();
              foreach (XmlNode discNode in childNode.ChildNodes)
              {
            foreach (XmlNode trackNode in discNode)
            {
              AmazonAlbumTrack track = new AmazonAlbumTrack();
              track.Number = Convert.ToInt32(trackNode.Attributes["Number"].Value);
              track.Title = trackNode.InnerText;
              tracks.Add(track);
            }
            discs.Add(tracks);
              }
              album.Discs = discs;
            }
              }

              return album;
        }
Exemplo n.º 2
0
        private AmazonAlbum FillAlbum(XmlNode node)
        {
            AmazonAlbum album = new AmazonAlbum();

            foreach (XmlNode childNode in node)
            {
                if (childNode.Name == "ASIN")
                {
                    album.Asin = childNode.InnerText;
                }

                if (childNode.Name == "SmallImage")
                {
                    album.SmallImageUrl = GetNode(childNode, "URL");
                    album.CoverWidth    = GetNode(childNode, "Width");
                    album.CoverHeight   = GetNode(childNode, "Height");
                }

                if (childNode.Name == "MediumImage")
                {
                    album.MediumImageUrl = GetNode(childNode, "URL");
                    album.CoverWidth     = GetNode(childNode, "Width");
                    album.CoverHeight    = GetNode(childNode, "Height");
                }

                if (childNode.Name == "LargeImage")
                {
                    album.LargeImageUrl = GetNode(childNode, "URL");
                    album.CoverWidth    = GetNode(childNode, "Width");
                    album.CoverHeight   = GetNode(childNode, "Height");
                }

                if (childNode.Name == "ItemAttributes")
                {
                    foreach (XmlNode attributeNode in childNode)
                    {
                        if (attributeNode.Name == "Artist")
                        {
                            album.Artist = attributeNode.InnerText;
                        }

                        if (attributeNode.Name == "Title")
                        {
                            album.Title = attributeNode.InnerText;
                        }

                        if (attributeNode.Name == "ReleaseDate")
                        {
                            album.Year = attributeNode.InnerText;
                        }

                        if (attributeNode.Name == "Binding")
                        {
                            album.Binding = attributeNode.InnerText;
                        }

                        if (attributeNode.Name == "Label")
                        {
                            album.Label = attributeNode.InnerText;
                        }
                    }
                }

                if (childNode.Name == "Tracks")
                {
                    // The node starts with a "<Disc Number Node" , we want all subnodes of it

                    List <List <AmazonAlbumTrack> > discs  = new List <List <AmazonAlbumTrack> >();
                    List <AmazonAlbumTrack>         tracks = new List <AmazonAlbumTrack>();
                    foreach (XmlNode discNode in childNode.ChildNodes)
                    {
                        foreach (XmlNode trackNode in discNode)
                        {
                            AmazonAlbumTrack track = new AmazonAlbumTrack();
                            track.Number = Convert.ToInt32(trackNode.Attributes["Number"].Value);
                            track.Title  = trackNode.InnerText;
                            tracks.Add(track);
                        }
                        discs.Add(tracks);
                    }
                    album.Discs = discs;
                }
            }

            return(album);
        }