3
votes

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

http://www.w3.org/2001/XMLSchema\" />

I get the following exception message:

{"http://www.w3.org/2001/XMLSchema'> was not expected."}

What did I miss ?

TIA,

1

1 Answers

2
votes

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.