[英]XmlSerializer not observing default namespace?
我有這個課:
[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,
查看XmlSerializer構造函數-
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.xmlserializer.aspx
您將要傳入“您的”命名空間,而不是w3c命名空間。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.