views:

82

answers:

1

I have this class:

 [Serializable]   
    public class Element 
    {
        [XmlAttribute("maxOccurs")]
        public int MaxOccurs{get; set;}
        [XmlAttribute("minOccurs")]
        public int MinOCcurs{get; set;}
        [XmlAttribute("name")]
        public string Name{get; set;}
        [XmlAttribute("nillable")]
        public bool IsNillable{get; set;}
        [XmlAttribute("type")]
        public string Type{get; set;}

    }

I have created an XmlSerializer like so:

XmlSerializer serializer = new XmlSerializer(elementType, "http://www.w3.org/2001/XMLSchema");

When I attemp to deserialize this sample XML

I get the following exception message:

{" was not expected."}

What did I miss ?

TIA,

A: 

Check out the XmlSerializer constructor -

http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.xmlserializer.aspx

You will want to pass in "your" namespace, not the w3c namespace.

Kris Krause
Thanks. I decided to just browse the attributes instead.
e28Makaveli