How to eliminate this exception when creating an XmlSerializer object?

I downloaded the XML Schema for XML Schemas at http://www.w3.org/2001/XMLSchema.xsd .

Then I used XSD.EXE to create the class from the downloaded file. I called the class schema.cs.

Then I executed this line of code:

XmlSerializer serializer = new XmlSerializer(typeof(schema));

and got this error:

The XML annotation element from the Namespace "http://www.w3.org/2001/XMLSchema" is already present in the current area.

How to find a duplicate element and fix it without breaking the circuit?

+3
source share
2 answers

I think the generated class has flaws.

, , .

/// <remarks/>
//[System.Xml.Serialization.XmlElementAttribute("annotation", typeof(annotation))]
[System.Xml.Serialization.XmlElementAttribute("Items", typeof(annotation))]
[System.Xml.Serialization.XmlElementAttribute("import", typeof(import))]
[System.Xml.Serialization.XmlElementAttribute("include", typeof(include))]
[System.Xml.Serialization.XmlElementAttribute("redefine", typeof(redefine))]
public openAttrs[] Items {
    get {
        return this.itemsField;
    }
    set {
        this.itemsField = value;
    }
}
+1

- , . XML XDocument .

0

Source: https://habr.com/ru/post/1771777/


All Articles