How to get this XmlAttribute

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 can get the type and id attributes ... but How do I get the "ext: score" one?

It works:

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

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

      

But it doesn't:

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

      

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

Any help?

+2


a source to share


2 answers


The attribute is called "score" and is in the namespace referenced by "ext", which is supposedly an alias for the xml namespace.

So find what "ext" displays (find xmlns) and add:



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

      

Edit; found here ; see xmlns:ext="http://example.org/ext-9.1#"

. Also note that the core objects seem to be in xmlns="http://musicbrainz.org/ns/mmd-1.0#"

, which might be required for an account at the root / object level.

+3


a source


ext

is the namespace of the attribute score

. Try specifying a namespace:



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

      

+1


a source







All Articles