Windows Phone 72010. 5. 27. 12:01

그냥 기본 1뎁스 


<ArticleData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ename>0</ename>
<sign>33</sign>
</ArticleData>


로드는 쉽다.. 클래스하나만 만듣면 되니깐 


하지만 하위 엘리먼트가 있는경우는?


예를 들어

<xavierresponse responsecode="200">
<fx_date>2010-05-26</fx_date>
<title>Xavier Finance - Exchange rates for 2010-05-26</title>
<link>http://finance.xaviermedia.com/</link>
<exchange_rates>
<basecurrency>EUR</basecurrency>
<fx_date>2010-05-26</fx_date>
<fx basecurrency="EUR">
<currency_code>EUR</currency_code>
<rate>1.0</rate>
</fx>
<fx basecurrency="EUR">
<currency_code>USD</currency_code>
<rate>1.230900</rate>
</fx>


이렇케 쭉 나가는거라면?


하위 안에 엘리먼트가 있고 또 안에 엘리먼트가 있으면


public class xavierresponse
{
[XmlElement]
public string fx_date { get; set; }

[XmlElement]
public List<exchange_rates> exchange_rates { get; set; }

[XmlElement]
public List<string> fx { get; set; }

[XmlElement]
public string basecurrency { get; set; }
}

public class exchange_rates
{
[XmlElement]
public string basecurrency { get; set; }

[XmlElement]
public string fx_date { get; set; }

[XmlElement]
public List<fx> fx { get; set; }
}

public class fx
{
[XmlElement]
public string currency_code { get; set; }

[XmlElement]
public string rate { get; set; }
}


이런식으로 하위의 엘리먼트들을 또 클래스로 만들어야 된다.


그러면 하위까지 긁어와서 보여준다..


물론 클래스 이름이랑 엘리먼트 이름이랑은 동일해야 한다.~


Posted by 동동(이재동)