views:

52

answers:

1

hi,

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"&gt;
    <rdf:type rdf:resource="http://s.opencalais.com/1/type/em/e/Country"/&gt;
    <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?

+1  A: 

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; }
}
Lachlan Roche
Worked like a charm, thanks. But it should be: [XmlAttribute("about", Namespace = "http://www.w3.org/1999/02/22-rdf-syntax-ns#", Form=XmlSchemaForm.Qualified)] public string Uri { get; set; }
Johnny