I'm trying to deserialize the following XML node (RDF actually) into a class.
<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; }
}
The name element is parsed correctly but the about attribute isn't. What am I doing wrong?
You need to specify that the attribute will be namespace qualified.
[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; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.