Error Deserializing Xml to Object - xmlns='' was not expected

后端 未结 3 446
情歌与酒
情歌与酒 2020-11-29 04:55

I am having real trouble trying to deserialize some XML and was hoping someone can offer some assistance. I have read a lot of similar posts but I am unable to resolve this.

3条回答
  •  情深已故
    2020-11-29 05:27

    I found doing the following fixed this for me

    if (elem.Attribute(XNamespace.Xmlns + "xsi") == null) {
        elem.Add(new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"));
    }
    
    if (elem.Attribute(XNamespace.Xmlns + "xsd") == null) {
        elem.Add(new XAttribute(XNamespace.Xmlns + "xsd", "http://www.w3.org/2001/XMLSchema"));
    }
    

提交回复
热议问题