2010-07-26 13 views
1

我试图使用restsharp连接到last.fm休息服务。我可以反序列化的实例中的简单数据:http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Cher&api_key=xxxxxxxxxxxxxxxxxxxxxxx在c#中使用restsharp消耗last.fm服务

然而,当我到达了艺术家的图片区:

<artist> 
    <name>Cher</name> 
    <mbid>bfcc6d75-a6a5-4bc6-8282-47aec8531818</mbid> 
    <url>http://www.last.fm/music/Cher</url> 
    <image size="small">http://userserve-ak.last.fm/serve/34/48511693.png</image> 
    <image size="medium">http://userserve-ak.last.fm/serve/64/48511693.png</image> 
    <image size="large">http://userserve-ak.last.fm/serve/126/48511693.png</image> 
    <image size="extralarge">http://userserve-ak.last.fm/serve/252/48511693.png</image> 
    <image size="mega">http://userserve-ak.last.fm/serve/500/48511693/Cher+Tess.png</image> 

我正在努力让图书馆的数据映射。这里是我到目前为止的代码:

namespace *******.Core.LastFm 
{ 
    using System.Xml.Serialization; 
    using System.Collections.Generic; 
    using System; 

    public class image 
    { 
     [XmlAttribute] 
     public string Size { get; set; } 

     public string Value { get; set; } 
    } 

    public class ArtistImageCollection : List<image> { } 

    public class Artist 
    { 
     public string Name { get; set; } 
     public string Mbid { get; set; } 
     public string Url { get; set; } 
     [XmlArray] 
     public ArtistImageCollection Image; 
    } 
} 

这是行不通的。有谁知道如何绑定这个?

[我更新,以反映网卡的建议 - 这不仍然工作]

我得到了基础,从这个代码:W http://www.aaronstannard.com/post/2010/06/14/How-to-Parse-a-Users-Delicious-Feed-with-RestSharp.aspx

://

回答

2

没有GET /图像上

设置DOH

+0

使用默认XmlDeserializer,不需要属性/所以不需要XmlArray属性的支持。 XmlAttribute不需要,因为它首先查找元素,然后查找属性。 – 2010-07-26 17:02:02

0

不要你需要使用[XmlArray]或类似的东西来注释[Attribute]和Image的大小?