views:

67

answers:

2

From the MusicBrainz REST service, I get the following xml:

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

Using WCF and XmlSerializationFormat, I'm able to get the type and id attributes... but How do I get the "ext:score" one?

This works:

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

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

But this doesnt:

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

It produces a serialization exception. I've also tried just using "score", but it doesn't work.

Any help?

+2  A: 

The attribute is named "score", and is in the namespace referenced by "ext", which is presumably an xml namespace alias.

So find what "ext" maps to (look for an xmlns), and add:

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

Edit; found it here; see xmlns:ext="http://example.org/ext-9.1#". Also note that the main objects seem to be in xmlns="http://musicbrainz.org/ns/mmd-1.0#" which you may need to account for at the root/object level.

Marc Gravell
A: 

The ext is the namespace of the score attribute. Try specifying the namespace:

[XmlAttribute(AttributeName="score", Namespace="the ext namespace")]
Daniel Rose