2010-04-29 5 views
2

을 얻는 방법, 나는 다음과 같은 XML을 얻을 :뮤직 브레인 REST 서비스에서이있는 XmlAttribute

<artist-list offset="0" count="59"> 
    <artist type="Person" id="xxxxx" ext:score="100"> 
    ... 

WCF와 XmlSerializationFormat를 사용하여, 나는 종류를 얻을 수 있어요 및 ID 속성 ...하지만 어떻게 할 "ext : score"를 얻으시겠습니까?

public class Artist 
    { 
    [XmlAttribute("id")] 
    public string ID { get; set; } 

    [XmlAttribute("type")] 
    public ArtistType Type { get; set; } 

을하지만이 나던 :

이 작동

[XmlAttribute("ext:score")] 
public string Score { get; set; } 

그것은 직렬화 예외를 생성합니다. 나는 또한 "점수"를 사용해 보았지만 작동하지 않습니다.

어떤 도움이 필요합니까?

답변

3

속성은 "score"로 이며 "xml namespace alias"인 "ext"에 의해 참조되는 네임 스페이스에 있습니다.

그래서 (AN의 xmlns 확인)에 무엇을 "내선"지도를 찾아 추가

[XmlAttribute("score", Namespace="http://example.org/ext-9.1#")] 
public string Score { get; set; } 

편집; 그것을 발견했다 here; xmlns:ext="http://example.org/ext-9.1#"을 참조하십시오. 또한 주 오브젝트는 xmlns="http://musicbrainz.org/ns/mmd-1.0#"에있는 것으로 루트/오브젝트 레벨에서 설명해야 할 수도 있습니다.

1

extscore 속성의 네임 스페이스입니다. 네임 스페이스를 지정하십시오.

[XmlAttribute(AttributeName="score", Namespace="the ext namespace")] 
관련 문제