Restsharp: XML์„ ๋ชฉ๋ก์œผ๋กœ ์—ญ์ง๋ ฌํ™”ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๊นŒ?

์— ๋งŒ๋“  2012๋…„ 04์›” 19์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: restsharp/RestSharp

์•ˆ๋…•ํ•˜์„ธ์š”, ์ €๋Š” Windows Phone 7.1 ํ”„๋กœ์ ํŠธ์—์„œ RestSharp๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์— XML ํ˜•์‹์˜ ์‘๋‹ต์ด ์žˆ์Šต๋‹ˆ๋‹ค.
https://skydrive.live.com/redir.aspx?cid=0b39f4fbbb0489dd&resid=B39F4FBBB0489DD!139 &parid=B39F4FBBB0489DD!103&authkey=!AOdT-FiS6Mw8v5Y

ํ•ด๋‹น ์‘๋‹ต์„ ํด๋ž˜์Šค์— ์—ญ์ง๋ ฌํ™”ํ•˜๋ ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค.

public class fullWall
{
    public _user user { get; set; }
    public int numberOfFriend { get; set; }
    public int numberOfPhoto { get; set; }
    public List<timhotPhotos> timhotPhotos { get; set; }
    public fullWall()
    {
        timhotPhotos = new List<timhotPhotos>();
    }
}

์—ฌ๊ธฐ์—์„œ ๋ณผ ์ˆ˜ ์žˆ๋“ฏ์ด timhotPhotos ๋ชฉ๋ก์„ ์ œ์™ธํ•œ ๋ชจ๋“  ์†์„ฑ์€ ๊ดœ์ฐฎ์Šต๋‹ˆ๋‹ค.

GitHub Logo

timhotPhotos ํด๋ž˜์Šค:

public class timhotPhotos
{
    public string id { get; set; }
    public string title { get; set; }
    public string description { get; set; }
    public string url { get; set; }
    public double width { get; set; }
    public double height { get; set; }
    public DateTime createdDate { get; set; }
    public _user user { get; set; }
    public int numOfComment { get; set; }
    public int numOfRate { get; set; }
    public int numOfView { get; set; }
    public bool rated { get; set; }
}

๋‚ด๊ฐ€ ์–ด๋””์—์„œ ์ž˜๋ชป ๋˜์—ˆ์Šต๋‹ˆ๊นŒ?

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์˜ค ๊ฐ์‚ฌ :)

Ps: ์ €๋Š” 21์„ธ ์†Œ๋…€์ž…๋‹ˆ๋‹ค. ๋งŒ๋‚˜์„œ ๋ฐ˜๊ฐ€์›Œ์š” :)

๋ชจ๋“  3 ๋Œ“๊ธ€

StackOverflow์—์„œ ๊ท€ํ•˜์˜ ์งˆ๋ฌธ ์„ ๋ณด์•˜๊ณ  ๊ฑฐ๊ธฐ์— ๋‹ต์žฅํ–ˆ์œผ๋ฉฐ ์ด์ œ ์—ฌ๊ธฐ์— ๋‚ด ๋‹ต์žฅ์„ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ธฐ๋ณธ XML deserializer๋ฅผ DotNetXmlDeserializer๋กœ ๋ณ€๊ฒฝํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

RestClient client;

client.AddHandler("application/xml", new DotNetXmlDeserializer());

๊ทธ๋Ÿฐ ๋‹ค์Œ ๋ชฉ๋ก์— XmlElement ํŠน์„ฑ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.timhotPhotos ์†์„ฑ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

public class fullWall
{
    public _user user { get; set; }
    public int numberOfFriend { get; set; }
    public int numberOfPhoto { get; set; }
    [System.Xml.Serialization.XmlElement()]
    public List<timhotPhotos> timhotPhotos { get; set; }
    public fullWall()
    {
        timhotPhotos = new List<timhotPhotos>();
    }
}

์ด์ œ ์ž˜ ์ž‘๋™ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค!

๊ทธ๋ฆฌ๊ณ  StackOverflow์—์„œ ๋‹ต๋ณ€์„ ์ˆ˜๋ฝํ–ˆ์œผ๋ฏ€๋กœ ์ด ๋ฌธ์ œ๋ฅผ ์ข…๋ฃŒํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ;)

์˜ค ๊ฐ์‚ฌ :)

Ps: ์ €๋Š” 21์„ธ ์†Œ๋…€์ž…๋‹ˆ๋‹ค. ๋งŒ๋‚˜์„œ ๋ฐ˜๊ฐ€์›Œ์š” :)

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰