2010-01-17 85 views
2

我有這個類:XmlSerializer不遵守默認命名空間?

[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;} 

    } 

我創建一個XmlSerializer像這樣:

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

當我學嘗試反序列化此示例XML

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

我收到以下異常消息:

{「http://www.w3.org/2001/XMLSchema'>不是預期的。」}

我錯過了什麼?

TIA,

回答