2010-03-08 2 views
3

다음 XML 노드 (실제로는 RDF)를 클래스로 deserialize하려고합니다.XML 비 직렬화 문제 (네임 스페이스가있는 특성)

<rdf:Description rdf:about="http://d.opencalais.com/genericHasher-1/dae360d4-25f1-34a7-9c70-d5f7e4cfe175"> 
    <rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Country"/> 
    <c:name>Egypt</c:name> 
</rdf:Description> 


    [Serializable] 
    [XmlRoot(Namespace = "http://www.w3.org/1999/02/22-rdf-syntax-ns#", ElementName = "Description")] 
    public class BasicEntity 
    { 
     [XmlElement(Namespace = "http://s.opencalais.com/1/pred/", ElementName = "name")] 
     public string Name { get; set; } 
     [XmlAttribute("about", Namespace = "http://www.w3.org/1999/02/22-rdf-syntax-ns#")] 
     public string Uri { get; set; } 
    } 

name 요소는 정확하게 구문 분석되지만 about 속성은 구문 분석되지 않습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

+0

하지 내가 대해 아는 지역하지만 당신이 RDF를 가지고 이상한 보인다 : 약 = "http://d.opencalais.com/genericHasher-1/dae360d4-25f1-34a7-9c70-d5f7e4cfe175 "XML에 있지만 XmlAttribute ("about ", 네임 스페이스 ="http://www.w3.org/1999/02/22-rdf-syntax-ns# ")] 입니다. 이게 맞습니까? –

+0

예. rdf : about 속성의 내용은 내가 원하는 것이며 네임 스페이스는 코드에 나타나는대로 있습니다. – Johnny

답변

5

속성이 네임 스페이스 한정임을 지정해야합니다.

[Serializable] 
[XmlRoot(Namespace = "http://www.w3.org/1999/02/22-rdf-syntax-ns#", ElementName = "Description")] 
public class BasicEntity 
{ 
    [XmlElement(Namespace = "http://s.opencalais.com/1/pred/", ElementName = "name")] 
    public string Name { get; set; } 

    [XmlAttribute("about", Form=XmlSchemaForm.Qualified, Namespace = "http://www.w3.org/1999/02/22-rdf-syntax-ns#")] 
    public string Uri { get; set; } 
} 
+0

부탁드립니다. 감사합니다. 그러나 다음과 같아야합니다. [XmlAttribute ("about", 네임 스페이스 = "http://www.w3.org/1999/02/22-rdf-syntax-ns#", Form = XmlSchemaForm.Qualified)] public string Uri {get; 세트; } – Johnny